WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Number Of Results In Search (11 posts)

  1. edie
    Member
    Posted 7 years ago #

    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)

  2. whooami
    Member
    Posted 7 years ago #

    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.

  3. edie
    Member
    Posted 7 years ago #

    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.

  4. whooami
    Member
    Posted 7 years ago #

    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(); ?>

  5. edie
    Member
    Posted 7 years ago #

    Thanks. Works perfectly :D

  6. tylerhauser
    Member
    Posted 7 years ago #

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

  7. tylerhauser
    Member
    Posted 7 years ago #

    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.

  8. tylerhauser
    Member
    Posted 7 years ago #

    Oh, my site is TwoWordHeap.com

  9. manhack
    Member
    Posted 6 years ago #

    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

  10. vossavant
    Member
    Posted 6 years ago #

    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.)

  11. iguana007
    Member
    Posted 6 years ago #

    GREAT!!! :)
    Thx for solution .... because this original plugin did not work for me in WP 2.5

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.