Exclude a Category from WordPress Search
- by admin
- 0
if we need to exclude 10, 11 categories posts from wordpress search then:
function search_exclude( $query ) {
if ( $query->is_search ) {
$query->set( ‘cat’, ‘-10, -11’ );
}
}
add_action( ‘pre_get_posts’, ‘search_exclude’);
if we need to exclude 10, 11 categories posts from wordpress search then: function search_exclude( $query ) { if ( $query->is_search ) { $query->set( ‘cat’, ‘-10, -11’ ); } } add_action( ‘pre_get_posts’, ‘search_exclude’);
if we need to exclude 10, 11 categories posts from wordpress search then: function search_exclude( $query ) { if ( $query->is_search ) { $query->set( ‘cat’, ‘-10, -11’ ); } } add_action( ‘pre_get_posts’, ‘search_exclude’);