Continue reading Scroll result page to the search term

Scroll result page to the search term

Relevanssi can highlight search terms on the posts. But how about scrolling the page to show the location where the search results are? That is also possible. It requires a bit of JavaScript on the post page. This script needs to run on the post page: The easiest way is to just add this to…

Read more Scroll result page to the search term 11 Comments on Scroll result page to the search term
Continue reading Category filter for search results pages

Category filter for search results pages

Sometimes it’s nice to have a category filter on the search results pages: a simple dropdown where you can choose the category you want to show. It’s easy to create one using wp_dropdown_categories() but on a search results page, that’s slightly problematic, as it’ll include all categories, not just those included in the search results.…

Read more Category filter for search results pages 33 Comments on Category filter for search results pages
Continue reading Filtering results by category

Filtering results by category

In order to filter search results by category, use the following code: $url = get_bloginfo(’url’); $url = esc_attr(add_query_arg(array(’cat’ => ’10’, ‘s’ => get_search_query()), $url)); echo "<a href=’$url’ rel=’nofollow’>Filter by category 10</a>";$url = get_bloginfo(‘url’); $url = esc_attr(add_query_arg(array(‘cat’ => ’10’, ‘s’ => get_search_query()), $url)); echo "<a href=’$url’ rel=’nofollow’>Filter by category 10</a>"; Put this in your search results…

Read more Filtering results by category 27 Comments on Filtering results by category
Continue reading Related searches feature

Related searches feature

John Blackbourn wrote a cool related searches feature for Relevanssi Premium. It’s included from version 1.7.4. In order to use the related searches, you must have search logging enabled and a good log of past searches. Then add the following code to your search results template in a suitable place: The first parameter is the…

Read more Related searches feature 21 Comments on Related searches feature
Continue reading Taxonomy archive search

Taxonomy archive search

This is a Premium feature and only applies when you index taxonomy terms. This does not apply in free Relevanssi. To include taxonomy pages (categories, tags, custom taxonomies) in the search, enable the option on the options page. There’s also the option to choose which taxonomies are included. By default empty terms (not linked to…

Read more Taxonomy archive search 49 Comments on Taxonomy archive search
Continue reading Changing the number of search results displayed

Changing the number of search results displayed

A standard way to change the number of search results displayed is something like this: Unfortunately, this breaks Relevanssi. Relevanssi hasn’t played nice with posts_per_page in any case, for some reason I don’t really understand — this is legacy code from the original wpSearch plugin. However, from Premium version 1.4.4 and free 2.9.2, you can…

Read more Changing the number of search results displayed 47 Comments on Changing the number of search results displayed
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.

Read more Category title in the search results page 1 Comment on Category title in the search results page