• nick_a

    (@nick_a)


    I was wondering if there was a way to display a different number of posts in the archives instead of the number defined in the admin for the index.

    For example, I have the “max posts to show” set at 5 in the admin. This applies fine for the index page. But if I sort the blog by date or category it still only displays the first 5. This is even if there are more than 5 posts in that category or date.

    Does anyone know a way around this?

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Dickie

    (@dickie)

    I would suggest setting the max no of posts in the settings to what you want for the categories and archives, and then edit the theme page for the front page index.php
    add
    <?php query_posts('showposts=NO_OF_POSTS'); ?>
    just before the loop. Replacing NO_OF_POSTS with the number that you want to show on the front page

    for example…

    <?php query_posts('showposts=5'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post();?>
    <!-- Code to print post here -->
    <?php endwhile; endif; ?>

    This all assumes that you have different archive and category template files. If you do not then you will need to create some.

    Thread Starter nick_a

    (@nick_a)

    Thanks, I will give that a try.

    spencerp

    (@spencerp)

    I’m not sure if this thread will help, or this plugin, but I heard good words about it.. =)

    https://www.ads-software.com/support/topic/24031?replies=33
    custom-query-string-plugin

    spencerp

    Hey all, I added <?php query_posts(‘showposts=NO_OF_POSTS’); ?> to my index.php file however there’s no longer a link to page/2 at the bottom of my main blog page… any ideas on how to show a set number of posts on the main index.php page whilst showing the settings described number of links in the archived pages and still getting the “Previous/Next” posts links to show??? Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Displaying a different number of posts in archives and index’ is closed to new replies.