Performancing Metrics

Limit Number Of Posts With WordPress

Justin Blanton shows how to limit the number of posts that are displayed on the index page of your WordPress 1.5 blog. You can set the Show At Most option but that is for all pages including archives.

Limit Number Of Posts With WordPress

One of the first things I noticed when I started to setup WordPress was that there was no way to control the number of posts displayed on the index page from the admin panel. Yes, there is the “Show at most” option, but this is a site-wide variable and works to treat all of your pages the same.

To limit the number of posts on your index page while allowing all other pages to look to the “Show at most” setting, check out Justin’s hack.

Categories: WordPress Tips

This post was written by . You can visit the for a short bio, more posts, and other information about the author.

Comments Closed


  1. mmedia says: 2/27/2005

    Hi, do you know what code must we insert inside “else { ?>”. I’m tried it, but int gives me many “parsers unexpected ‘{‘ or ‘<’ errors”.

    Sorry by this question, but Justin doesn’t allow comments in his blog.


  2. John says: 2/27/2005

    You need to add the first snippet of code at the beginning of your loop right after

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

    then add <?php $ctr++; } ?&#62 right before the &#60?php endwhile; ?>

    That should do it for you. Also, be sure to change the X to the number of posts you want displayed on the index.php page.

  3. mmedia says: 2/27/2005

    Thanks for your answer, John, but I have this in the code:

    “< ?php static $ctr = 0;
    if ($ctr == "1") { break; }
    else {

    } ?>

    and I have this message:

    “Parse error: parse error, unexpected ‘< ' in /home/proyecto/public_html/sol/wp-content/themes/sol/index.php on line 60"

    line 60 is "


  4. John says: 2/27/2005

    I would need to see all of the code because many times the line number given in the error is not the correct line. Sometimes it’s the line before.

    But it appears you just have an extra <\ somewhere.

    Also, you can’t just post the code in a WordPress comment box because WordPress will trash it. Send the index file to me via email. john at johnhesch dot com.

  5. Dusky says: 2/27/2005

    There’s a plug-in available that does the same, and a bit more. Save it to your computer, configure it to match your needs, upload it, and activate it.

Performancing Metrics
EatonWeb Portal