Continue reading Auto-redirecting with one search result

Auto-redirecting with one search result

…wp_redirect( get_permalink( $wp_query->posts[‘0’]->ID ) ); exit(); } } } This is not Relevanssi-specific and works just fine even without Relevanssi. If you are using Relevanssi on a multisite system, you need a small change to the code: add_action( ‘template_redirect’, ‘one_match_redirect’ ); function one_match_redirect() { if ( is_search() ) { global…

Read more Auto-redirecting with one search result 15 Comments on Auto-redirecting with one search result
Continue reading Excluding protected posts

Excluding protected posts

A site I’m working with has a handful of “protected” posts (password required to view). For various reasons, we don’t want to show these in search results. While there is no excerpt shown, I’d prefer for people to not even know they exist. Relevanssi sees protected posts as public posts (because their post status is…

Read more Excluding protected posts 14 Comments on Excluding protected posts
Continue reading Indexing attachment file names

Indexing attachment file names

…( ‘attachment’ === $post->post_type ) { $content .= ‘ ‘ . basename( $post->guid ); } return $content; } Notice that by default Relevanssi replaces periods with spaces, so “sample.pdf” is indexed as “sample pdf”. That should not be a problem, as also in searching “sample.pdf” becomes “sample pdf”. However, if…Relevanssi has been working nicely for the normal usecase. But how does one setup indexing of attachment files. When someone searches by a file name or an extension like pdf, there are no results. I have enabled ‘attachment’ at Relevanssi ‘Indexing options’ and still there are no results. Relevanssi doesn’t…

Read more Indexing attachment file names 7 Comments on Indexing attachment file names
Continue reading Different fuzzy search setting on different searches

Different fuzzy search setting on different searches

setting from the relevanssi_fuzzy option. WordPress provides you with pre_option_relevanssi_fuzzy filter you can use to change the value. The values are “always” and “sometimes”, and everything else counts as none. So, set the setting to always from Relevanssi settings, and then add a filter function that sets the value to,……it on the employees/department search? Yes, you can, but it takes some hacking. Since Relevanssi has just one setting for the fuzzy search, you need to change it on the fly for one of the searches. It’s probably easier to do with the relevanssi_do_query() search. Relevanssi reads the fuzzy search……for example, “none” when you’re doing an employee/department search. For example, you can set a global variable before the relevanssi_do_query(), like this: global $relevanssi_disable_fuzzy; $relevanssi_disable_fuzzy = true; relevanssi_do_query( $args ); Then use that global variable as a trigger: add_filter( ‘pre_option_relevanssi_fuzzy’, ‘rlv_disable_fuzzy’ ); function rlv_disable_fuzzy( $value ) { global $relevanssi_disable_fuzzy; if…

Read more Different fuzzy search setting on different searches 0 Comment on Different fuzzy search setting on different searches
Continue reading Indexing the post ID

Indexing the post ID

Are post ID’s searchable in Relevanssi? No. Relevanssi does understand the WP_Query p parameter to restrict the search by post ID. However, if you want to search by post ID, it’s very simple to make that happen using the relevanssi_content_to_index filter hook: Add that to theme functions.php, reindex and searching for post ID’s works. Originally…

Read more Indexing the post ID 2 Comments on Indexing the post ID
Continue reading How to index parent categories

How to index parent categories

Suppose you have a parent category with no products in it but a child category does. If you search by the parent category can relevanssi be set up to show the products in the child category? Cars > Wiper Blades. A search for cars shows wiper blade products. By default this does not work, because…

Read more How to index parent categories 3 Comments on How to index parent categories
Continue reading bbPress: Indexing topics and replies

bbPress: Indexing topics and replies

Relevanssi does work with BBPress. BBPress forums, topics and replies are regular WordPress posts. In order to get Relevanssi working with BBPress, you need to make Relevanssi index post type topic (forget forum, and I think it’s better if you skip reply as well). Since topic is non-public post type, you also need to uncheck…

Read more bbPress: Indexing topics and replies 6 Comments on bbPress: Indexing topics and replies