Preview:
// 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' );
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter