How To Hide Posts And Pages From Search Engines?

How To Hide Posts And Pages From Search Engines?

How To Hide Posts And Pages From Search Engines?


Have you ever wanted to How To Hide Posts And Pages From Search Engines? for example, from internal search results on your site? Or want to block search engines from crawling to your posts and pages. Here I will show you how to so so.

Or even better, hide the pages reserved for members in the members area or pages containing sensitive information, for example, in the case of a Membership site (obviously the contents will always remain password protected but it is prevented from being displayed and therefore from being aware of their existence).

Even if you had never thought about it, I advise you to reflect on this problem. Some pages should never be viewed by the user who does an internal search on the site, or that should never be indexed by search engines also for a matter of privacy of your customers.

By default, WordPress has an internal search function that shows both posts and pages published based on the search term or keyword. Usually, the contents that make up a site are found within the articles, and users are more inclined to search for articles than pages.

The pages, on the other hand, are used to provide different information such as the site’s biography, privacy, cookie policy, login, and more. Usually, the pages are links present in a menu or the footer, so it is sometimes even convenient, to exclude WordPress pages from the internal search of the site or search engines.

You can block search engines from crawling your WordPress pages from the site’s internal search or search engines without using any plugin, only through the same settings provided by WordPress or by adding PHP code to the function.php file of the active theme.

But let’s get to practice now and see how to hide WordPress pages from search results.

How to hide WordPress pages from internal search results on your site?


Method 1: Using function.php file

To exclude WordPress pages from the search results within your site, add some PHP code inside the function.php file of your theme in use on WordPress.

Anyone wishing to hide all the pages of their WordPress site can do so by going to Appearance> Editor>functions.php and pasting the following code:

functionSearchFilter ($ query) {
if ($ query->is_search) {
$ query-> set ('post_type', 'post');
return $ query;
add_filter ('pre_get_posts', 'SearchFilter');

Through this code, only articles or posts will appear in searches , all pages will be excluded.

If, on the other hand, you are not familiar with adding codes directly in the WordPress theme file, I recommend the best WordPress plugins useful for this purpose, such as Exclude or Search Exclude, which will allow you to exclude WordPress pages and articles from the search directly from the settings plugins.

Method 2:Using header.php file


In WordPress, there is already a setting that allows you to prevent indexing pages and posts on search engines. Usually, this setting is recommended to select it, only and exclusively, when you intend to create a private blog accessible only to specific groups of users who are already informed of the existence of the site.

Virtually all sections of a WordPress site are indexable by search engines, including the internal search results page. We can block the contents of your WordPress site to search engines with a simple trick.

Let’s see below the ways and solutions to hide pages from search engines but make them accessible via direct URL and without the use of specific plugins.

Add the following code in the file header.php, inside the element head:

[phphtmlscript = "true"] <? php if (is_search ()) {?><meta name = "robots" content = "noindex, nofollow" /><? php}?>

Alternatively, create a robots.txt file (it will probably already be present in your WordPress hosting ) that looks like this:


* Disallow:

Method 3:  Using robots.txt file:


User-agent: * Disallow: /

To avoid indexing a specific page or post with the robots.txt file:

User-agent: * Disallow: / pages / hidden_page

instead of / pages / hidden_page, enter the URL of the page you want to hide.

Finally, another way, more straightforward and less risky to inhibit the indexing of WordPress pages and posts is to select the item “Discourage search engines from indexing this site” which is located at inside the path:

Warning: this procedure will make your WordPress site virtually invisible to search engines.

If you check the option ” Discourage search engines from indexing this site, “the system inserts the meta tag <meta name = “robots” content = “noindex, nofollow”> in the header of all pages, warning in thus all search engines that pages will not have to be taken into account and therefore not included in the index of their search databases.

Method 4: Using All in One SEO Pack Plugin

Another aspect to consider when hiding pages and posts from your site is the indexing done by Google and other major search engines (Bing and Yahoo). Also, in this case, the contents you want to limit visibility must not be included (think, for example, of pages containing sensitive information of your customers).

The plugin that helps us, in this case, is the famous Yoast SEO or the beloved All in one SEO Pack  (tools to do SEO and optimize the positioning on google and the various search engines of your articles and web pages with WordPress). This plugin allows us to avoid indexing specific WordPress pages and posts.

With All in One SEO Pack activated,  you can prevent Google crawlers from accessing specific pages and exclude selected pages from being indexed on Google.

Now, scrolling down the page and article editor, you will see the All in One SEO Pack panel appear and further down the Meta Robot NoIndex entry (or TAG).

By selecting the Meta Robots No Index TAGspecific pages and posts will not be indexed. They will not be included in the Google index. At the same time, make sure that the pages and posts you want to hide are not included in the sitemap of your WordPress site or blog.

Method 5: Password protect any page or post in wordpress

This method rather that not indexing a page or post from search engine, will set a password to get access into the site. The owner can decide on whom to pass on the password and give access to the site to only to them.

Under the quick edit section of your post or page you can see a password section where you can set one for yourself. Also you can set the page/post attribute to private so that only you can have the access to it.

How To Hide Posts And Pages From Search Engines?

The bottom line on how to block search engines on a site or specific WordPress articles

We’ve seen how to hide pages and posts from your site’s search results, the Google index, and search engines in general. Now you know how to improve and refine the WordPress search functionality

If you know other solutions to hide pages and posts on your site or new strategies to prevent content that should have protected visibility from being publicly accessible, please keep us informed by leaving a comment in the appropriate box!


About Post Author

You Might Also Like