0

I did my WordPress website design with Elementor plugin and i included a menu in the side bar of every page, now i face a problem with search results because searching any word from the menu gives a huge number of results, it's normal because i have a menu in all pages.

I want to know how can i exclude this side menu from search result?

0

Copy below code and paste in function.php file to exclude pages from search results.

if (!is_admin()) {
    function wpb_search_filter($query) {
        if ($query->is_search) {
            $query->set('post_type', 'post');
        }
        return $query;
    }
    add_filter('pre_get_posts','wpb_search_filter');
}
|improve this answer|||||
  • Thank you for your response, but what i want is to hide a part of a page from search results page not the entire page – sihamxxi Jun 4 '19 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.