Hi there! Ok I want this question to be understood properly. I have a WordPress blog with lots of content in the form of articles published as posts. I have few pages as well. Yet I want some of the pages not to appear on the WordPress site when a search for relevant word is being performed. For instance I have articles with the topic of XYZ, and when a keyword of that topic is being placed in the search filed of the website itself (not google) , the results sometimes show a page that I would want to be displayed (like a thank you page for instance). So what can I do so certain pages don't appear when people write related term in the search field. * I've set Google to not index them, but that is not what I'm asking. Thank you!
You can either use above plugin or put below code in Wordpress theme's Function.php: function jp_search_filter( $query ) { if ( ! $query->is_admin && $query->is_search && $query->is_main_query() ) { $query->set( 'post__not_in', array( 20 ) ); } } add_action( 'pre_get_posts', 'jp_search_filter' ); In the above example page id 20 will be excluded from search