Continue reading Using the relevanssi_hits_filter hook

Using the relevanssi_hits_filter hook

A very useful hook relevanssi_hits_filter, which lets you modify the hits directly. The filter passes an array, where index 0 gives the list of hits in the form of an array of post objects and index 1 has the search query as a string, in case you need that information for something. The filter is very…

Read more Using the relevanssi_hits_filter hook 10 Comments on Using the relevanssi_hits_filter hook
Continue reading Using the relevanssi_where hook

Using the relevanssi_where hook

If you want to add extra filters to the search results, you can add them using a hook. Relevanssi searches for results in the _relevanssi table, where terms and post_ids are listed. The various filtering methods work by listing either allowed or forbidden post ids in the query WHERE clause. Using the relevanssi_where hook you can…

Read more Using the relevanssi_where hook 27 Comments on Using the relevanssi_where hook
Continue reading Using unusual character sets

Using unusual character sets

Some people have reported problems with Relevanssi and non-English characters, mostly accented letters. The problem here isn’t with Relevanssi, which handles UTF-8 characters without problems (if you’re not using Unicode, but some other character set, you may indeed be out of luck). The issue lies with MySQL. If you’re having troubles, try switching the collation on…

Read more Using unusual character sets 30 Comments on Using unusual character sets
Continue reading Showing the number of search results

Showing the number of search results

If you want to show the number of search results found on the search results template, you can find the value in the variable $wp_query->found_posts. Just add <?php echo ‘<p>Found ‘ . $wp_query->found_posts . ‘ hits.</p>’; ?> in your search results template. In case that produces no results, try introducing the global $wp_query variable like…

Read more Showing the number of search results 4 Comments on Showing the number of search results