Exclude specific pages from search results

Home Forums Legacy Support Support queries How-to & Troubleshooting Exclude specific pages from search results

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #193278
    mderooij
    Spectator
    I would like to exclude specific pages and posts from the search results, but don't know how to do it. I tried it with the 'Search Exclude' plugin, but that doesn't work out. Any ideas?
    #193355
    logan
    Member
    Hey, Please goto wp-admin > wplms > course manager > hide course from directory, Refer: http://prntscr.com/mahsun let me know if you need any further information.  
    #193521
    mderooij
    Spectator
    It is more about the search results of the whole website. Any page and post shows up there. So how to excluded a page from the website search results?
    #193732
    logan
    Member
    #193784
    mderooij
    Spectator
    Hi, The plugin doens't work with this theme :-( And the other way (functions.php) also doesn't work. I think that code is only for Wordpress posts and not for Wordpress pages?
    #193921
    logan
    Member
    We have tested the code and its working for us : function wpb_search_filter($query) { if ($query->is_search) { $query->set('post__not_in', array(76,78)); } return $query; }   add_filter('pre_get_posts','wpb_search_filter',99999);     In above code put your page ids , comma separated : " array(76,78,2,108)  "
    #194314
    mderooij
    Spectator
    Thanks, that worked for me also
    #194443
    logan
    Member
    Hey There, Voila ! If I can be of assistance, please do not hesitate to contact me again. Closing this topic. Best regards :)  
Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Exclude specific pages from search results’ is closed to new replies.