Continue reading Restricting the indexing to particular user roles

Restricting the indexing to particular user roles

From the Relevanssi settings, you can only choose whether subscribers are indexed or not. If you need finer control over what user roles are indexed by Relevanssi, you can use the following code. Place it in your theme functions.php: add_filter(’relevanssi_user_index_ok’, ‘rlv_do_not_index_admins’, 10, 2); function rlv_do_not_index_admins($do_index, $user) { $block_these_roles = array(’administrator’, ‘editor’, ‘author’, ‘contributor’, ‘subscriber’);  …

Read more Restricting the indexing to particular user roles 0 Comment on Restricting the indexing to particular user roles
Continue reading Excluding posts by taxonomy

Excluding posts by taxonomy

Relevanssi has a category exclusion feature built in, but that only works for basic categories and not any other taxonomies. You can use tax_query to restrict the searches as well, but that’s more complicated than adjusting the setting in Relevanssi settings. However, if the exclusion is permanent, it’s best done in the indexing level. That…

Read more Excluding posts by taxonomy 8 Comments on Excluding posts by taxonomy
Continue reading Deindexing Yoast SEO noindex posts

Deindexing Yoast SEO noindex posts

If you use Yoast SEO to mark posts “noindex”, you may want to have Relevanssi deindex those posts as well. It’s easy to do using the relevanssi_do_not_index hook. Just add this function to your theme functions.php: add_filter(’relevanssi_do_not_index’, ‘rlv_yoast_noindex’, 10, 2); function rlv_yoast_noindex($do_not_index, $post_id) { $noindex = get_post_meta($post_id, ‘_yoast_wpseo_meta-robots-noindex’, true); if ($noindex) $do_not_index = true; return…

Read more Deindexing Yoast SEO noindex posts 1 Comment on Deindexing Yoast SEO noindex posts
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 8 Comments on Excluding protected posts
Continue reading Indexing attachment filenames

Indexing attachment filenames

Relevanssi has been working nicely for the normal usecase. But how does one setup indexing of attachment files. When someone searches by filename or extension like pdf, there are no results. I have enabled ‘attachment’ at Relevanssi ‘Indexing options’ and still there are no results. Relevanssi doesn’t index attachment file names. For attachments, Relevanssi indexes…

Read more Indexing attachment filenames 0 Comment on Indexing attachment filenames
Continue reading Searching by post ID

Searching by 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: add_filter(’relevanssi_content_to_index’, ‘rlv_index_post_id’, 10, 2); function rlv_index_post_id($content, $post) { $content .= " " . $post->ID; return $content; }add_filter(‘relevanssi_content_to_index’, ‘rlv_index_post_id’,…

Read more Searching by post ID 0 Comment on Searching by 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 0 Comment on How to index parent categories