Okay. I am not on here often, but I finally gave up trying to debug this myself. I’ve got a custom post type, with custom taxonomies, and I want a certain number of post thumbnails to show up on a page, and paginate through the others. When clicked on, the URL paginates as it should (showing /page/1/, /page/2/, etc.) however, the same 4 posts show, and will not rotate to the older or newer posts. I’ve tried different structures, and pagination techniques, but all seems to have failed. Help?
Also–I’m working locally, so it’s pretty inconvenient that you can’t see the website itself, but I will do my best to provide further information and/or screenshots. Thank you.
<div class="masonryGalleryTheme"> <?php $args = array( 'taxonomy' => 'portfolio_categories', 'term' => 'artwork', 'post_type' => 'portfolio', 'posts_per_page' => 4 ); $comments = new WP_Query($args); if ($comments->have_posts()) : while ($comments->have_posts()) : $comments->the_post(); ?> <a href="<?php the_post_thumbnail_url(); ?>" rel="lightbox" title="<?php the_title(); ?> - <?php the_excerpt(); ?>"> <?php the_post_thumbnail(); ?> </a> <?php endwhile; endif; ?> <?php wp_reset_query(); ?> </div> <?php next_posts_link('« Older Entries', $comments->max_num_pages); ?> <?php previous_posts_link('« Newer Entries', $comments->max_num_pages); ?>
I’m sure this will turn out to be a simple solution–and if so, I apologize for my stupidity in advance. XD
I think you forgot to add this to your query args. By adding this page parameter WP will show the posts that would normally show on page=x.
// So that WordPress will know which page to show $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; // Our query args array. $args = array( 'taxonomy' => 'portfolio_categories', 'term' => 'artwork', 'post_type' => 'portfolio', 'posts_per_page' => 4, 'paged' => $paged );
If this does not work, let me know. 🙂