If you want to hide pages from appearing when your readers use the default WordPress search box on your website, you have several options.
- Install the Simply Exclude plugin
- Install the Search Everything plugin
- Add different PHP code to your child themes functions.php file
The Simply Exclude plugin will enable you to select which specific pages or posts you don’t want appearing in your sites search results.
The Search Everything plugin enables you to exclude posts and categories from displaying in the default WordPress search functions results.
Code Snippets
Here’s several code snippets you can use to exclude pages and posts from displaying in your search results on your site.
This code returns search results for posts only and excludes all pages from displaying on your sites search results when your readers use your search box.
This code removes all posts from displaying in your search results and only returns results for pages.
This code removes a post type, in this case pages, from search results when using the default WordPress search function.
Conclusion
You can also exclude posts assigned to one or more categories from displaying in your RSS feed.
Leave a Reply
You must be logged in to post a comment.