Created
May 21, 2012 10:30
-
-
Save j100002ben/2761739 to your computer and use it in GitHub Desktop.
Example of "posts_clauses_request" filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function search_posts_clauses_request($clauses, $wp_query){ | |
global $wpdb; | |
if(is_plugin_active('wp-cjk-fulltext-index/wp-cjk-fulltext-index.php')){ | |
$key = get_query_var('key'); | |
cjkfxi_set_posts_clauses_request($clauses, $key); | |
} | |
extract($clauses, EXTR_SKIP); | |
$found_posts_query = " SELECT COUNT(*) FROM $wpdb->posts $join WHERE 1=1 $where"; | |
$wp_query->found_posts = $wpdb->get_var( $found_posts_query ); | |
$wp_query->found_posts = apply_filters_ref_array( 'found_posts', array( $wp_query->found_posts, &$wp_query ) ); | |
$wp_query->max_num_pages = ceil($wp_query->found_posts / $wp_query->query_vars['posts_per_page']); | |
remove_filter('posts_clauses_request', 'search_posts_clauses_request', 10, 2); | |
return $clauses; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment