This topic has 2 replies, 2 voices, and was last updated 7 years by Laura.

  • Author
  • #159930
     joy
    Participant

    I currently have “post” set for the search filter, but the results also includes “pages”. How can I prevent this from happening?

    #159931
     joy
    Participant

    Nevermind, I got it. 🙂

    COPY CODE
    function remove_pages_from_search($query) {
    if ($query->is_search) {
    $query->set('post_type', 'post');
    }
    return $query;
    }
    add_filter('pre_get_posts','remove_pages_from_search');
    #160019
     Laura
    Moderator

    Glad you could resolve it 🙂

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

Viewing 3 posts - 1 through 3 (of 3 total)

The forum ‘Bugs & Issues’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?