Jump to content

Next / Previous Buttons not working in WordPress Theme


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(); ?>

<?php the_title(); ?>

<?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>'); ?>

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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.