Determining Author post count

This thread on the wordpress codex shows how you can scope your SQL query: $author_post_count = $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->posts WHERE post_author=”” . $$username->ID . “” AND post_type=”post” AND post_status=”publish””);

How can I use the WordPress Loop and Pagination in multiple instances but different scenarios throughout my site?

In your main loop file, check the $args. It filters the query. you can use the same query on other pages using your own options. suppose, on another page, you want to fetch the posts of a different category. your query parameters may be like: $args = array( ‘post_type’ => ‘post’, ‘cat’ => ‘DIFFERENT_CATEGORY’, ‘posts_per_page’ … Read more

Replacing global wp_query

Firstly, I’d seriously consider opting for another plugin (it hasn’t been maintained in over 2 years), or making use of WP’s built-in paginate_links. But, in the quest to provide a solution, give this a go: function wp_page_numbers_custom( $wp_query, $start=””, $end = ” ) { $_backup = array( ‘wp_query’ => @ $GLOBALS[‘wp_query’], ‘max_page’ => @ $GLOBALS[‘max_page’], … Read more

Custom Query Not Paginating

You need to set paged or an offset in your query, otherwise you’re always fetching the same 48 posts. $page = (get_query_var(‘page’)) ? get_query_var(‘page’) : 1; $args = array( ‘paged’ => $page, ‘posts_per_page’ => ’48’, ‘cat’ => ‘4’, ‘meta_query’ => array( array( ‘key’ => ‘Country’, ‘value’ => $country_search_array, ‘compare’ => ‘IN’ ) ) ); $gallery_query … Read more

Can’t query by meta_key

Thanks for @dunc and @helgatheviking I got the answer. Here’s my code. You need the post type declared, otherwise it resorts to “post”. I also couldn’t do this unless I put meta_key and meta_value in a ‘meta_query’ multidimensional array. $args = array( ‘post_type’ => ‘tsa_events’, ‘meta_query’ => array( array( ‘key’ => ‘slideshow_image’, ‘value’ => array(”), … Read more

For what queries is conditional tags informative?

is_category(‘apple’) might give a false response if “banana” AND “apple” has been queried you’re using is_category incorrectly in this context. From Codex: is_category(); // When any Category archive page is being displayed. A category archive page is for a single term, if a query is a for more than one term, it’s not a term … Read more

Use Ajax To filter posts?

I’d go with @Vinicius’ answer with the following changes: Change type: ‘GET’ to type: ‘POST’ Change ajax: 1 to action: ‘filter_posts’ Replace add_action(‘init’, ‘check_ajax’); with: add_action(‘wp_ajax_filter_posts’, ‘check_ajax’); add_action(‘wp_ajax_nopriv_filter_posts’, ‘check_ajax’); Remove: if (!isset($_POST[‘ajax’])) return false;