Continue reading Doing a multisite search

Doing a multisite search

Multisite search only works in Relevanssi Premium. Installing multisite Relevanssi Relevanssi is a network plugin, so it only needs to be installed once on network level. However, you need to activate the plugin and build the index for each site. On the other hand, you can adjust the settings for each blog. Changes to search…

Read more Doing a multisite search 125 Comments on Doing a multisite search
Continue reading Category title in the search results page

Category title in the search results page

If you’re using category restriction dropdown on your search form, here’s a bit of code that you can add to your search results template to show how many hits were found and what the category is. If no category was selected, this’ll just show how many hits were found. <?php $cat = get_cat_name($wp_query->query_vars[‘cat’]); $s =…

Read more Category title in the search results page 1 Comment on Category title in the search results page
Continue reading User profile search

User profile search

Relevanssi Premium can search user profiles. So far the following data gets indexed from user profiles: first name, last name, display name and description. If you’re interested in having something else indexed, there’s an option in the options page. Because WordPress only handles posts in the search result pages, Relevanssi must make WordPress believe it’s…

Read more User profile search 67 Comments on User profile search
Continue reading “Did you mean” suggestions

“Did you mean” suggestions

Relevanssi has Google-style “did you mean” suggestions for queries. There’s a difference between free Relevanssi and Relevanssi Premium on how this is done. Free Relevanssi bases the suggestions on logged queries by the users of the blog; the wisdom of the crowds, so to speak. That requires the use of search query logging to be…

Read more “Did you mean” suggestions 103 Comments on “Did you mean” suggestions
Continue reading Filter search results by date

Filter search results by date

You can specify date limits on searches with by_date search parameter. Here’s a link you can add to your search results page to offer your visitor the ability to restrict the search results to last day: <?php echo ‘<p><a href=”‘ . get_bloginfo(‘url’) . ‘?s=’ . get_search_query() . ‘&by_date=1d”>results from the last day</a></p>’; ?> Search for something at RAPLIQ…

Read more Filter search results by date 11 Comments on Filter search results by date
Continue reading Sorting search results

Sorting search results

If you want something else than the default relevancy ranking, you can use orderby and order parameters for the search query. Orderby accepts $post variable attributes and order can be asc (ascending) or desc (descending). The most relevant attributes here are most likely post_date and comment_count. If you want to give your users the ability…

Read more Sorting search results 36 Comments on Sorting search results
Continue reading Direct access to the query engine

Direct access to the query engine

Relevanssi can’t be used in any situation, because it checks the presence of search with the is_search() function. This causes some unfortunate limitations and reduces the general usability of the plugin. You can, however, access the query engine directly. There’s a function called relevanssi_do_query(), which can be used to do search queries just about anywhere. Here’s a…

Read more Direct access to the query engine 57 Comments on Direct access to the query engine
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