WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Category Pagination (9 posts)

  1. Darfuria
    Member
    Posted 4 years ago #

    I'm using the following code:

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
    <?php query_posts('posts_per_page=2&cat=4'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="tutorial">
    <div class="image"></div>
    <div class="text">
    <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    <?php the_content(); ?>
    </div>
    <div class="cboth"></div>
    </div>
    <?php endwhile; endif; ?>
    <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>

    And whilst it generates the pagination, when one clicks on the pagination links, the index.php template is loaded - and therefore page 2 of the results isn't shown at all.

  2. MichaelH
    Member
    Posted 4 years ago #

    Try changing:

    <?php query_posts('posts_per_page=2&cat=4'); ?>

    to

    <?php query_posts($query_string . '&posts_per_page=2&cat=4'); ?>
  3. Darfuria
    Member
    Posted 4 years ago #

    Unfortunately that didn't resolve it.

    Just noticed that it's 404ing, not just loading the index.php (I don't have a 404 page in place yet, and only just noticed the "Page not found" message).

    I'm using category-4.php for this code.

    The URL is http://www.mywebsite.com/category/
    And the pagination generates the following URL: http://www.mywebsite.com/category/page/2/ which 404s.

  4. MichaelH
    Member
    Posted 4 years ago #

    If you are using category-4.php then you really don't need to put a cat= clause in query_posts as WordPress will do that automatically.

    Switch to the WordPress Default theme. So if you want to make category 4 posts be 'different' then copy the archives.php to category-4.php and see if you have problems. Then try to use that template with your theme.

  5. Darfuria
    Member
    Posted 4 years ago #

    Alright, I'll try that. Thanks.

  6. Darfuria
    Member
    Posted 4 years ago #

    Hi there. I tried this and was still unable to get the pagination to work correctly. As soon as I clicked on page 2 I got a 404.

  7. Darfuria
    Member
    Posted 4 years ago #

  8. brownapples
    Member
    Posted 4 years ago #


    Plugin above really works!!!
    I strongly recommend it for fixing next pagination error.
    Thx!!!!

  9. Darfuria
    Member
    Posted 4 years ago #

    It should also be noticed that the pagenavi should have gone above the endif;

Topic Closed

This topic has been closed to new replies.

About this Topic