Skip to main content

Forums

This topic contains 1 reply, has 0 voices, and was last updated by  chrisburton 8 years, 7 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #31635

    chrisburton
    Participant

    I noticed when you search for a page (ex. Home, Contact) on my website you get just that. How can I exclude pages from being searched?

    #60209

    chrisburton
    Participant

    This reply has been reported for inappropriate content.

    For future reference to anyone wanting to fix this problem.
    Add this to your theme’s functions.php file

    function SearchFilter($query) {
    if ($query->is_search) {
    $query->set('post_type', 'post');
    }
    return $query;
    }

    add_filter('pre_get_posts','SearchFilter');
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

icon-link icon-logo-star icon-search icon-star