Support » Themes and Templates » search.php – displaying different number then the number of posts

  • Qbs

    (@qbs)


    in my admin panel I’ve set WP to display 3 posts per page and it works but I’ve noticed that this also influences the number of search results…

    I’d like all of my search results to be displayed on one single page, how do I do that?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Qbs

    (@qbs)

    I reckon that the easiest way would be to change $posts_per_page; but I can’t figure out ho to change it just for the search.php template

    Qbs

    (@qbs)

    I’ve found something like <?php query_posts('posts_per_page=-1&post_type=post'); ?>
    but for the love of god I can’t make it show ONLY the search results

    help…

    Place

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

    before

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

    Place
    <?php $posts=query_posts($query_string . '&posts_per_page=-1'); ?>
    before
    <?php while (have_posts()) : the_post(); ?>

    Because WordPress already has executed the original query for the page before it reaches your query_posts() call, you are nearly doubling the number of database calls made using this method. I suggest you check out this short article for a more efficient way to do achieve this goal.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘search.php – displaying different number then the number of posts’ is closed to new replies.