H friends, hope doing good. Today I am going to share a very useful tutorial how to exclude a custom post type from search. If you want to exclude a custom post type from your website search option, then this tutorial is designed for you.
Below is an example which will exclude a custom post type from search results. Open functions.php file from your current activated WordPress theme and copy paste below code at the end of the file.
$args = array(
'exclude_from_search' => false, // the important line here!
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title','editor','author','thumbnail','excerpt','comments')
If you still need any help to with your WordPress website, then feel free to put your comments in below comment section. I will be happy to help you. If you like this tutorial, do you like & share this article with your friends, and don’t forget to follow us on Facebook and Twitter to learn cool WordPress tutorials.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.