How get pagination to work when querying for custom type posts on a category
-
Hi there,
I’m developing a theme that features custom type posts called “projects” and regular posts which are displayed on the blog page.
On the homepage I’d like to display only the “project” custom type posts that are in the category “featured”. I’d like this to paginate as I want to use infinite scroll.
I have read all the documentation and tried every single trick, but I can get this page to display the pagination and I can’t figure out what I’m doing wrong.
This is how I’m running my loop:
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $temp = $featured; // assign ordinal query to temp variable for later use $featured = null; $featured = new WP_Query(array( 'post_type' => 'projects', 'category__in'=> 14, 'post_status' => 'publish', 'posts_per_page' => 1, 'paged' => $paged)); ?> if ( $featured->have_posts() ) while ( $featured->have_posts()) : $featured->the_post(); <div id="content"> </div> <?php endwhile; ?> <?php wp_reset_postdata(); // reset the query ?> <div class="pagination"> <span class="pag-next"><?php next_posts_link(); ?> </span> <span class="pag-previous"><?php previous_posts_link(); ?></span> </div>
Apologies, if this is not the right place where to post this question. I tried the WP_Advanced forum but it said only moderators can post there (?)
Any help would be much appreciated!
- The topic ‘How get pagination to work when querying for custom type posts on a category’ is closed to new replies.