function exclude_post_from_search( $query ) { if ( $query->is_search && !is_admin() ) { $query->set( 'post__not_in', array( 37430 ) ); } return $query; } add_filter( 'pre_get_posts', 'exclude_post_from_search' );