plugins - How to exclude a part of a page in search results

I did my WordPress website design with Elementor plugin and i included a menu in the side bar of every page, now i face

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?

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?

Share Improve this question asked Jun 3, 2019 at 14:18 sihamxxisihamxxi 351 silver badge6 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 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');
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745439977a4627785.html

相关推荐

  • plugins - How to exclude a part of a page in search results

    I did my WordPress website design with Elementor plugin and i included a menu in the side bar of every page, now i face

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信