Forum Replies Created

Viewing 1 replies (of 1 total)
  • Todd

    (@toddbeyond5280com)

    I needed to exclude one page from the results that is a modal and should only be viewed that way. I modified the code from Tim and thought I would put it here in case anyone else just has 1 page that needed to be excluded. 460 is the page id that needed to be excluded, so just replace that with the id of the page you want to exclude

    function mySearchFilter($query) {
        if ($query->is_search) {
            $excludeId = 460;
            $query->set('post__not_in', array($excludeId));
        }
        return $query;
    }
    add_filter('pre_get_posts','mySearchFilter');
Viewing 1 replies (of 1 total)