ControlledChaos
8/8/2016 - 3:13 PM

Exclude pages from the WordPress search function.

Exclude pages from the WordPress search function.

<?php

function ccd_exclude_pages_from_search() {
    global $wp_post_types;
    $wp_post_types['page']->exclude_from_search = true;
}
add_action( 'init', 'ccd_exclude_pages_from_search' );

?>

Exclude Pages from Search

WordPress Snippet