function imnobby_transient_ajx_response_demo(){ $transient_name = "my_query_cache"; // Display Transient Data Directly If Available if ( !(false === ( $response_json = get_transient( $transient_name ))) ) { echo $response_json; exit; } $response_json = do_your_query_functions_here(); set_transient( $transient_name , $response_json, 60 ); // Store Transient for 60 Seconds echo $response_json; exit; } add_action('wp_ajax_imnobby_transient_ajx_response_demo', 'imnobby_transient_ajx_response_demo'); // For Logged-in Users add_action('wp_ajax_nopriv_imnobby_transient_ajx_response_demo', 'imnobby_transient_ajx_response_demo' ); // For Unauthenticated Users function do_your_query_functions_here(){ $tmphtml = ""; return $tmphtml; } // Related Plugin: Transients ManagerRelated Keywords: Developer, How-to, Solved, WordPress Cache Data, Cache Content, Get Transient Function
喜歡這篇文章嗎?





(暫時未有評分)
Loading...





(暫時未有評分)
