Home › Forums › Support › Exclude Pages from Blog Search This topic has 3 replies, 2 voices, and was last updated 4 years, 4 months ago by David. Viewing 4 posts - 1 through 4 (of 4 total) Author Posts January 11, 2019 at 6:36 am #779117 Kulwant Hi, I want to remove all pages and other types of pages from the search on my blog. i.e when someone searches anything on my blog, they must see only posts. Here I searched https://www.bloggingcage.com/?s=black+friday It’s showing all the pages too and some coupon archive pages too. January 11, 2019 at 7:26 am #779256 DavidStaff Customer Support Hi there, you can use the WP pre_get_posts query: function search_filter($query) { if ( !is_admin() && $query->is_main_query() ) { if ($query->is_search) { $query->set('post_type', 'post'); } } } add_action('pre_get_posts','search_filter'); https://docs.generatepress.com/article/adding-php/ January 11, 2019 at 7:28 am #779258 Kulwant It worked. 🙂 Thanks a lot. January 11, 2019 at 7:32 am #779261 DavidStaff Customer Support You’re welcome. Author Posts Viewing 4 posts - 1 through 4 (of 4 total) You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In