Jump to content

Next / Previous Buttons not working in WordPress Theme


Ricky55

Recommended Posts

Hi Guys


Struggling to get this working. This code appears on my page-blog.php When the links are clicked the url changes to /page/2/ etc but the posts themselves don’t change. I have some very similar code in my single.php and its working fine. My code is below, what am I doing wrong?



<section role="main">

<?php $page = get_page_by_title('the blog'); $content = apply_filters('the_content', $page->post_content); echo $content; ?>

<?php $blog_posts = new WP_Query(); $blog_posts->query('showposts=5');
if ( $blog_posts->have_posts() ) : while ( $blog_posts->have_posts() ) : $blog_posts->the_post(); ?>

<article>
<?php the_title(); ?>
</article>

<?php endwhile; ?>

<nav id="post-nav">
<span class="prev"><?php next_posts_link( '← View Older Posts', $blog_posts->max_num_pages ); ?></span>
<?php previous_posts_link('<span class="next">' .( 'View more Recent Posts →' ). '</span>'); ?>
</nav>

<?php else: ?>
<p>Sorry it looks like you need to add some posts to this blog!</p>
<?php endif; wp_reset_query(); ?>

</section>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.