Numeric pagination custom post type

You’re referencing the global $wp_query object in your function which you’ve reset using wp_reset_query(). You can resolve the pagination by passing your custom $loop WP_Query object to the function. I also changed wp_reset_query to wp_reset_postdata Also you’re making the call to your pagination function in the while loop instead of after it. Your function should … Read more

3 posts from each existing category on one page

I found a problem. I had to change this: $args = array( ‘cat’ => $category->name, ‘posts_per_page’ => 3,); for this: $args = array( ‘category_name’ => $category->name, ‘posts_per_page’ => 3,); In first code I was passing category name which is string to argument expecting ID of category. Here is Codex reference where I found solution: category_name … Read more

2 queries with counters

On the advise of Robert and Pieter I rewrote the loops using WP_Query instead of query_posts. It works now. Thanks guys. Here’s the code: <ul class=”tabs”> <li class=”tab-link current” data-tab=”tab-1″>Most Popular</li> <li class=”tab-link” data-tab=”tab-2″>Recent</li> </ul> <div id=”tab-1″ class=”tab-content current”> <div class=”slider”> <div class=”slide”> <?php $count = 0; $query = new WP_Query( array( ‘meta_key’ => ‘post_views_count’, … Read more

Problem with different query loops (and “main loop”) on category template page!

In order to provide more-specific help, we’ll need to know greater detail regarding exactly what’s happening that you don’t expect, or what’s not happening that you expect to happen, or what is happening differently from what you expect. That said, there are at least two things that will likely help you: Use descriptive and unique … Read more

Reset postdata to custom query in nested queries

You can save the $post in some temp variable and just set the $post back to the temp variable global $post; while ( have_posts() ) : the_post(); //Set up custom query $args = array( //Query args ); $custom_query = new WP_Query( $args ); //Custom query loop: while ( $custom_query->have_posts() ) : $custom_query->the_post(); // Save global … Read more