Ashley Cameron Design

Ashley Cameron Design

Shop the Creative Design Market

Goodnight

Exclude Posts or Pages from WordPress Search Results

SnippetsWordPress

About a 1 minute read

"It is the supreme art of the teacher to awaken joy in creative expression and knowledge."

Albert Einstein


1
2
3
4
5
6
7
8
9
//exclude posts from search
function SearchFilter($query) {
    if ($query->is_search) {
        $query->set('cat','0,1');
    }
    return $query;
}

add_filter('pre_get_posts','SearchFilter');