Reputation: 6380
I'm using the WP-PageNavi plugin to paginate my news area. It's not quite working as intended.
I have a total of 6 news items published, but I've offset it by 1 so it doesn't show the latest. With the pagination it's showing the same 5 news items on page 1 and 2. I've set the posts per page to be 5 so it shouldn't even be showing the page 2 link. The url does however change to page1 and page2.
There's probably something stupid I've done wrong!
<?php $portfolioloop = new WP_Query( array( 'paged' => get_query_var('paged'), 'post_type' => 'blog', 'posts_per_page' => 5, 'sort_order' => 'DESC', 'offset' => 1)); ?>
<?php while ( $portfolioloop->have_posts() ) : $portfolioloop->the_post(); ?>
<div class="blog-item"> <img width="163" src="<?php echo the_field('image'); ?>" alt="<?php echo the_title(); ?>" />
<div class="news-item">
<p><?php echo the_time('F j, Y'); ?></p>
<h2><?php echo the_title(); ?></h2>
<p>
<?php $content = get_the_content();
if(strlen($content) > 120 ){
echo substr($content,0,120) . "...";
}else{
echo substr($content,0,120);
} ?>
<br />
<a class="read-more" href="<?php echo get_page_link($post->ID) ?>">Read more...</a> </p>
</div>
<div style="clear:both"></div>
</div>
<?php endwhile; // end of the loop. ?>
<p class="news-page"><?php echo wp_count_posts('blog')->publish; ?> news items</p>
<?php if (function_exists('wp_pagenavi')) { wp_pagenavi( array( 'query' => $portfolioloop ) ); } ?>
Upvotes: 0
Views: 1341