Exclude certain pages from WordPress search results

PHOTO EMBED

Sat May 29 2021 08:08:13 GMT+0000 (UTC)

Saved by @ma57t

// Exclude certain pages from WordPress search results
//======================================
function jp_search_filter( $query ) {
  if ( ! $query->is_admin && $query->is_search && $query->is_main_query() ) {
    $query->set( 'post__not_in', array( 827,851 ) );
  }
}
add_action( 'pre_get_posts', 'jp_search_filter' );
content_copyCOPY