• Resolved svenvaeth

    (@svenvaeth)


    Hi, I am using your calendar with superowly theme.

    It is a bit confusing that the default search finds our events and mixes them up with blog posts.
    You can see on our website. Try and type “chur” (town in Switzerland) and you will find some events first and then our blog posts.

    Is there a way to exclude the events from this search? The event search is sufficient.

    Thanks,
    Sven

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter svenvaeth

    (@svenvaeth)

    Nobody has an answer???

    Hey there @svenvaeth!

    Thanks for reaching out — sorry to hear that you are experiencing difficulties.

    I apologize for the wait, we’ve been experiencing a high volume of requests.

    Give this snippet a shot in your functions.php file:

    function exclude_from_search($query) {
        if ($query->is_search) {
            $query->set('post_type', array( 'post', 'page' ) );
        }
        return $query;
    } 
    add_filter('pre_get_posts','exclude_from_search');

    Take care,
    Ed ??

    Thread Starter svenvaeth

    (@svenvaeth)

    Thanks, that worked out!

    Thread Starter svenvaeth

    (@svenvaeth)

    Resolved

    You’re welcome!

    I’m going to go ahead and close out this thread — don’t hesitate to create a new one any time you need help!

    Take care,
    Ed ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Exclude events from WP site search’ is closed to new replies.