I am trying to exclude custom post types from the main wordpress search. I have custom searches for custom post types with Relevanssi integration.
Following this: https://toolset.com/documentation/user-guides/creating-wordpress-custom-post-archives/
hidden link is an example of a search that includes user profile posts when I only need pages and posts to show.
When creating the WordPress Search archive, there is no way to exclude posts. I'd like to be able to edit the output like here: https://toolset.com/forums/topic/exclude-post-type-from-website-search-results-archive/#post-1138852
Thanks!
Hello,
In your case, you can try these:
Dashboard-> Toolset-> Post Types, find and edit those specific post type, for example "user profile".
In section "Options", enable option: exclude_from_search
And test again.
More help:
https://developer.wordpress.org/reference/functions/register_post_type/#exclude_from_search
exclude_from_search
(boolean) (importance) Whether to exclude posts with this post type from front end search results.
HI, Kind of interesting. I checked off exclude_from_search in the post type, but the posts are still included in the search results for users who are logged in. I have set Relevanssi to respect excluded posts. Is there another step?
Thank you!
Since you are using Relevanssi integration in the search result WordPress Archive, Relevanssi plugin will take over the search result query, Toolset Blocks/Views plugin can only display the results. So the problem should be in Relevanssi plugin.
Please try these:
1) Follow our document, to exclude index of your specific post type in Relevanssi plugin side:
https://toolset.com/course-lesson/searching-texts-in-custom-fields-with-toolset-and-relevanssi/#including-custom-posts-in-the-search
section "Including custom posts in the search"
2) Deactivate Toolset Blocks/Views plugin
3) Test the search result page again
4) If the problem still persists, it should be a problem of Relevanssi plugin, see our document:
https://toolset.com/course-lesson/searching-texts-in-custom-fields-with-toolset-and-relevanssi/