WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Number Of Results In Search

[Resolved] Number Of Results In Search

  • I’d like to show how many results there were in a search. For example I’d like it to say:

    There were 5 posts containing the word “whatever”.

    Thanks to anyone who can help with this :o)

Viewing 10 replies - 1 through 10 (of 10 total)
  • whooami

    @whooami

    Member

    what version of wordpress are you using?

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

    Thats the link to the fixed plugin for WP2.2 that does that.. the link to the original, which will probably work in earlier versions is linked inside that post.

    Please note — that is NOT my plugin. I just fixed it for 2.2 compatibility.

    Awesome thank you so much. I guess Im an airhead, but how do I call it? Ive tried everything. I dont know much about PHP.

    whooami

    @whooami

    Member

    yeah, I thought that might come up πŸ™‚ Again, not my plugin, and amazingly the author didnt include a readme or anything.

    Its simple though actually.

    Wherever you want the display, add this:

    <?php wp_searchheader(); ?>

    Thanks. Works perfectly πŸ˜€

    Fantastic!!! This is so simple and so amazing.

    Ah but I’m having issues… The Search Results plugin work very well except when displaying more than 5 results. When I search for the word “the” I get this…

    “Showing results 1 – 5 of 5 for the search terms: the.”

    and then

    “Showing results 6 – 5 of 5 for the search terms: the.”

    for the next page and so on. I took a look at the plugin code but PHP confounds me. Is there something wrong with the plugin or is it just me?

    Oh and I’m getting this whenever I edit my search.php page or activate/deactivate plugins I get this error…

    Warning: Cannot modify header information – headers already sent by (output started at /home/content/a/l/r/alronhauser/html/wp-content/plugins/resultscount.php:67) in /home/content/a/l/r/alronhauser/html/wp-admin/theme-editor.php on line 55

    I’m so sad cause I thought this was such a great plugin.

    Oh, my site is TwoWordHeap.com

    The problem :

    Warning: Cannot modify header information – headers already sent by (output started at

    can be fixed if you delete the blank character wich follows the

    php>

    at the end of the script

    If this topic still needs an answer, try this. No plug-in required, and deceptively simple. Just add this line of code before your while 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.)

    GREAT!!! πŸ™‚
    Thx for solution …. because this original plugin did not work for me in WP 2.5

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Resolved] Number Of Results In Search’ is closed to new replies.