WordPress.org

Ready to get started?Download WordPress

Forums

Relevanssi - A Better Search
[resolved] [Plugin: Relevanssi] Search result count (6 posts)

  1. Lee Hord
    Member
    Posted 3 years ago #

    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.

    http://wordpress.org/extend/plugins/relevanssi/

  2. Mikko Saari
    Member
    Plugin Author

    Posted 3 years ago #

    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.

  3. wasferraz
    Member
    Posted 3 years ago #

    I have the same problem!

  4. Mikko Saari
    Member
    Plugin Author

    Posted 3 years ago #

    See the first item in the FAQ for a solution.

  5. mlopezart
    Member
    Posted 3 years ago #

    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?

  6. Mikko Saari
    Member
    Plugin Author

    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags