I’m having a problem with my WordPress theme. My next_posts_link()
only reloads the same page. Here’s my code.
<div id="main">
<?php query_posts('category_name='.get_the_title().'&post_status=publish,future');?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="utdrag">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<div class="crop"><a href="<?php the_permalink(); ?>">
<?php
if ( get_the_post_thumbnail($post_id) != '' ) {
echo '<a href="'; the_permalink(); echo '" class="thumbnail-wrapper">';
the_post_thumbnail();
echo '</a>';
} else {
echo '<img src="';
echo catch_that_image();
echo '" alt="Image unavailable" class="crop" />';
echo '</a>';
}
?></a>
</div>
<?php the_excerpt(); ?>
</div>
<?php endwhile; else: endif; ?>
<?php next_posts_link();?><?php previous_posts_link();?>
</div>
I’m using a static page as my front page. As you can see it’s only displaying posts that have the same category as the page title: query_posts('category_name='.get_the_title().'&post_status=publish,future');
This is something I want to keep. So does anyone know why it just reloads? Why it isn’t changing to the next page?
I figured it out! I’m posting it here in case someone else is having the same problem!
I added this code at the top:
And replaced this:
with this:
For more information, check out this link:
http://wordpress.org/support/topic/front-page-wp-query-pagination-issue-repeating-posts-next_posts_link-help
These two functions does not work on static pages.
From the documentation for
wp_next_post_link()
:However, take a look at this article. It talks about how to create a static front page with dynamic content.