Support » Fixing WordPress » Limiting Search Page Posts to 10 Per Page from Infinite

  • Hey Guys,

    I’m trying to limit the amount of posts per page on my website. Currently when you type something in the search bar it lists every post from the beginning of time. I’d like it to be 10. Here’s how my code reads:

    <?php if (have_posts()) : ?>
    <div id="left" class="pageContentArea">
    <article class="post">
    <h1>Results for '<?php the_search_query(); ?>'</h1>
    <?php include (TEMPLATEPATH . '/_/inc/post/nav.php' ); ?>
    <?php while (have_posts()) : the_post(); ?>
    <article <?php post_class() ?> id="post-<?php the_ID(); ?>">
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <div class="entry">
    <?php the_excerpt(); ?>
    <?php endwhile; ?>
    <?php include (TEMPLATEPATH . '/_/inc/post/nav.php' ); ?>

    Do you have any reccommendations on what I need to add in order to achieve this?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi Schillingry,

    Have you tried updating the setting on your backend?

    Go to Settings > Reading and see what value you have for “Blog pages show at most”.

    Hey Ryan,

    Yeah, currently that reads 5 which is how the News page outputs. However on the search results page it shows every post from the most recent to the oldest. I just want to make it to where only the 10 show and if you want to see more you click to another page.

    Right now about 300 show so the page is crazy long. Any suggestions?

    Could you post the url for the search result page?
    Also can you post the code from search.php using


    Hey Ryan,

    Thanks for your help. Here is the url of the search.php

    The url to the search results page is

    I’m looking into it as well, however any help is greatly appreciated!

    Hey Ryan,

    I think I was able to get it corrected. I added:

    <?php query_posts($query_string . '&showposts=10'); ?>

    Right above the
    <?php if (have_posts()) : ?>

    and it looks like it is only displaying 10 now.

    Hi Schillingry,

    Find the line

    <?php if (have_posts()) : ?>

    and add the code below above the line

    <?php query_posts($query_string . '&showposts=20'); ?>

    20 is the number of posts you want to display.

    Let me know how it goes.

    Oops, you’ve already figured it out haha

    Great, looks like we came up with the same thing.

    Thank you very much for looking into this with me!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Limiting Search Page Posts to 10 Per Page from Infinite’ is closed to new replies.