• Hi everyones,

    I am building a kind of blog for my website and I got a page where I’m listing all my posts. I would like to place, for example, 5 posts per page. If I got 25 posts per example, I could click on “Next page” and it would bring me on the /page2/ with the 5 next.

    Actually… The pages are changing but all the posts are the same.

    To do this, I’ve try some different things like going in the admin and change the number of posts per page in the settings > Reading.

    I’ve tried this too. Just erased the HTML codes to let you see my code:

    <!-- Query -->
    <?php query_posts('cat=Chasse & Pêche'); ?>
    
    <!-- The Loop -->
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    <div class="post">
    <!-- The posts who have been loop with the query -->
    </div>
    
    <?php endwhile; endif; ?>
    
    <div class="navigation">
    <?php posts_nav_link('-', 'Prev', 'Next'); ?>
    </div>

    If you guys got solutions, please let me know how I could be able to change the posts with the different pages!

    Thx

Viewing 1 replies (of 1 total)
  • Thread Starter Patrice Poliquin

    (@poliquinp)

    I just found something that actually works great.

    Instead of :

    <!-- Query -->
    <?php query_posts('cat=Chasse & Pêche'); ?>
    
    <!-- The Loop -->
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    Use this :

    <?php if (have_posts()) : ?>
         <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("category_name=somecat&paged=$paged"); ?>
            <?php while (have_posts()) : the_post(); ?>

    You can change the “category_name by something you want!

    Let me know it anwser your questions!

Viewing 1 replies (of 1 total)
  • The topic ‘Posts on different pages issues’ is closed to new replies.