Support » Plugin: Relevanssi - A Better Search » [Plugin: Relevanssi] Search result count

  • Resolved Lee Hord


    I’m using the following code to show the number of search results returned:
    <h3>Search Result for <?php $allsearch = &new WP_Query("s=$s&showposts=-1"); $key = wp_specialchars($s, 1); $count = $allsearch->post_count; _e(''); _e('<span class="search-terms">'); echo $key; _e('</span>'); _e(' &mdash; '); echo $count . ' '; _e('results'); wp_reset_query(); ?></h3>

    This works fine with the standard WordPress search, however seems to be incorrect when used with Relevanssi. Has anyone else experienced this? Can’t seem to figure out solution.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mikko Saari


    Yes, I should probably add this to FAQ: this doesn’t work. It pretty much shows the hit count a regular WordPress search would find.

    Sorry, I don’t have a working solution for this, but I would be very interested to hear if somebody else has.

    I have the same problem!

    Plugin Author Mikko Saari


    See the first item in the FAQ for a solution.

    Enable your original Search (from wp’s widget) and paste the code into your header.php (or wherever you wish to place it). Do this DURING your Relevanssi plugin is activated. Both will work hand in hand, with WP search doing the post count, and R doing the rest.

    MAJOR ISSUE though, R plugin doesn’t show the searched image, but everything else does. The reason is the image is named the same. Without turning off the highlighting feature, is there a better way to fix this?

    Plugin Author Mikko Saari


    There’s no need to use any extra codes, when

    <?php echo 'Relevanssi found ' . $wp_query->found_posts . ' hits'; ?>

    does the trick and always shows the correct amount of hits.

    The search term highlighting breaks images if the search term appears in the image code. There’s no way around it except to disable the search term highlighting in posts. It will be fixed in the next release.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Relevanssi] Search result count’ is closed to new replies.