WordPress.org

Ready to get started?Download WordPress

Forums

Number of Search Results (11 posts)

  1. eleni2
    Member
    Posted 7 years ago #

    Hi,

    I actually have TWO questions.

    1. Is it possible to display the total number of search results? Is there a tag for this (or even a plugin)?

    2. I want my search results to show more than the number of my regular entries. For example, in my admin, I set my blog to show the latest 5 entries. However in the search results, I would like for it to display 10 per page. How can this be achieved?

    Thank you so much!

  2. whooami
    Member
    Posted 7 years ago #

    2. custom posts per page: http://rephrase.net/miscellany/05/perpage.phps

    1. yes, but I dont remem. how :P

  3. Michael Bishop

    Posted 7 years ago #

  4. eleni2
    Member
    Posted 7 years ago #

    Can someone still help me with #1? I used to have a solution called 'search results' plugin but it no longer works in WP 2.1. Thanks!

  5. whooami
    Member
    Posted 7 years ago #

    <?php
    $mySearch =& new WP_Query("s=$s & showposts=-1");
    $NumResults = $mySearch->post_count;
    echo $NumResults;
    ?>

    doesnt that work?

  6. eleni2
    Member
    Posted 7 years ago #

    nope. it only shows the number of results on the current page. my search results are paginated.

  7. tylerhauser
    Member
    Posted 7 years ago #

    Still no solution on this???

  8. whooami
    Member
    Posted 7 years ago #

    tylerhauser,

    still no solution to what..? whats the problem that needs a solution?

  9. whooami
    Member
    Posted 7 years ago #

    the search results plugin was abandoned -- I fixed it to work with 2.2, and more than like 2.1 ...

    http://www.village-idiot.org/archives/2007/05/26/search-results-count-plugin/

  10. tylerhauser
    Member
    Posted 7 years ago #

    There's no solution to showing the total number of returned posts for a search that has paginated results.

  11. vossavant
    Member
    Posted 6 years ago #

    I know this topic got dropped a while ago, but I found an answer:

    To count the total number of search results for a search that has paginated results, simply add this above your loop:

    $hit_count = $wp_query->found_posts;

    For example, my search results page looks like this:

    <?php if (have_posts()) : ?>
    
    <?php $hit_count = $wp_query->found_posts; // count # of search results ?>
    <p>Your search for <b>'<?php the_search_query(); ?>'</b> returned <?php echo $hit_count . ' results'; ?></p>

    .
    .
    .
    (while loop, etc.)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.