So I built a blog for someone but I'm having an issue with the homepage. The homepage is set to show 9 posts before the pagination turns on (set in WP admin settings), but when you click on page 2, 3 or any number, it shows the same content as page 1 (note that the url will display the right /page/#) but it always shows the first 9 latest posts and still has page one selected in the pagination.

In my WP settings I have the front page display set to "your latest posts" and in my index.php being used as the homepage, I'm simply calling the loop and pagination:

<?php get_template_part('loop'); ?>
<?php get_template_part('pagination'); ?>

Using that code in my category templates works perfectly as the pagination functions right and always shows the right posts per page.

I've seen similar questions posted, but in those cases they're using custom queries.

The loop (same for the categories with working pagination):

<?php if (have_posts()): while (have_posts()) : the_post(); ?>

    <!-- article -->
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

        <!-- post details -->
        <span class="loop_cat"><?php the_category(' '); ?></span>
        <span class="date"><?php the_time('Y.m.d'); ?></span>

        <!-- post thumbnail -->
        <?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
            <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
                <?php the_post_thumbnail('full'); // Declare pixel size you need inside the array ?>
        <?php endif; ?>
        <!-- /post thumbnail -->

        <?php echo do_shortcode('[Sassy_Social_Share]'); ?>

        <!-- post title -->
            <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
        <!-- /post title -->

        <a href="<?php get_custom_field('buy-link', TRUE); ?>" target="_blank"><h4 title="Purchase"><?php get_custom_field('price', TRUE); ?></h4></a>

        <div class="divider_excerpt"></div>

        <?php html5wp_excerpt('html5wp_index'); // Build your custom callback length in functions.php ?>

        <!-- <?php edit_post_link(); ?> -->

    <!-- /article -->

<?php endwhile; ?>

<?php else: ?>

    <!-- article -->
        <h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2>
    <!-- /article -->

<?php endif; ?>


<!-- pagination -->
<div class="pagination">
    <?php html5wp_pagination(); ?>
<!-- /pagination -->


Turns out this line of code I had right above the rest to exclude a specific category from the homepage loop is what caused the issue:

 <?php if (is_home()) {
 ;} ?>
  • Any messing with main query, such as query_posts() or alike?
    – Rarst
    Jul 19, 2016 at 19:21
  • Nope! No custom queries on the site, didn't add anything query related to my functions file either.
    – Sam Assoum
    Jul 19, 2016 at 19:28
  • What does the pagination template file actually look like? ('pagination').
    – CK MacLeod
    Jul 19, 2016 at 21:07
  • Well I started with the HTML5 Blank theme for my custom theme, I left the pagination file as is, as well as the functions file. I added the pagination code to my question above.
    – Sam Assoum
    Jul 20, 2016 at 0:23
  • This has to be a bad filter or pre_get_posts action, or maybe a rewrite rule somewhere. Your code works out-of-the-box, nothing wrong there, the problem is somewhere else. Look in all you plugins and theme for any instance of pre_get_posts, query_posts or any posts_* filter or any code that might change your rewrite rules. Apart from that, there is absolutely nothing in your code that can cause this epic failure Jul 20, 2016 at 5:41

1 Answer 1


Turns out this line of code I had right above the rest to exclude a specific category from the homepage loop is what caused the issue:

    <?php if (is_home()) {
    ;} ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.