Posted on

Why is a post type excluded from search?

In the list of post types to index in the Relevanssi indexing settings tab there’s a column “Excluded from search”, which has a value of “yes” or “no” for each post type. What does this mean, and why does the value remain “yes” even if you set Relevanssi to index that post type?

This column is strictly for information only, and does not govern what Relevanssi does. This is something that is defined when a post type is registered. Some post types are meant for public use (like post or page) and thus are not excluded from the search. Other post types are meant for somewhat internal use (like product_variation posts in WooCommerce, which are shown as part of the product, not alone) or completely for internal use (like revision for post revisions), and these post types are excluded from the search.

Relevanssi post type indexing settings
It’s possible to index the book post type, even though it has been excluded from the search.

Relevanssi can index posts that are excluded from the search. If you have indexed an excluded post type, the column will still say the post type is excluded from the search, because the setting that is defined when the post type is registered has not changed: it’s still the same. Relevanssi just doesn’t care about it and still indexes the post.

The setting does affect Relevanssi in that when Relevanssi does search posts, Relevanssi does respect this setting and will exclude these posts from the searches. That’s often for the best; there’s almost always a good reason why these post types are excluded from the search in the first place. However, sometimes there are situations where it would be useful to include these excluded posts in the search. That’s possible with Relevanssi: all you need to do is to uncheck the “Respect exclude_from_search” option in the Relevanssi searching settings.

The Respect exclude_from_search setting
As you can see, Relevanssi will suggest you need to uncheck this option if you choose to index an excluded post type.

In many cases it’s good to stop and think before you index an excluded post type: there’s a good chance things will not work the way you expect if you do that. There’s probably another way to do what you’re thinking you’re doing.

Leave a Reply

Are you a Relevanssi Premium customer looking for support? Please use the Premium support form.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.