Sunday, November 29, 2020
Home Blogging How to Exclude Pages from WordPress Search Results

How to Exclude Pages from WordPress Search Results

By default, WordPress Search function shows revealed posts and revealed pages in search results. Usually when customers are on the lookout for one thing in a weblog, it’s more than likely a publish somewhat than a web page. On this article, we’ll present you make your search extra related and fewer crowded by excluding pages from WordPress search results.

First, you add the next code to your theme’s features.php file or a site-specific plugin.

//Exclude pages from WordPress Search
if (!is_admin()) {
function wpb_search_filter($query) {
if ($query->is_search) {
$query->set('post_type', 'post');
return $query;

Clarification: This code first checks that the search just isn’t originating from the WordPress admin pages. If it isn’t, then it searches for posts by setting the post_type parameter.

You can too make it do the alternative by setting the post_type to pages, so it solely return pages within the search results.

You May Also Like : Making Your WordPress Mobile Friendly with WPtouch Pro

We hope this text helped you discover ways to exclude pages from WordPress search results. You might also wish to see our checklist of greatest WordPress search plugins to enhance your website search.

If you liked this article, make sure to hit the bell for getting our latest updates and share this article with your friends in every social media platforms.



Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular

How to Start Dropshipping Business in India and Make Money Through it in 2020

If you're planning on beginning a dropshipping business in India, the time is correct now. Ecommerce or shopping for stuff on the Internet is...

An Internship Guide about DRDO

Defense Research Development Organization (DRDO) provides an internship to graduates and submit graduate college students. If you're on the lookout for a profession in DRDO...

How to Become a Pilot: Eligibility, Training, Study & Salary

Every little one dreamt of flying. Some wished to fly as passengers whereas others wished to grow to be pilot, taking plane hovering into...

10 Best Online Money Transfer Apps & e-Wallets in India

There was a time when sending cash from one place to a different concerned standing in lengthy financial institution/publish workplace queues, patiently awaiting your...

Recent Comments