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?

Introduction

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 make sure that that post is not indexed on search engines?

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 hide 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

Hide-WordPress-Post-Page-From-Google

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.

How to hide WordPress pages and posts from search engines without using plugins

Hide-WordPress-Post-Page-From-Google

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:

User-agent:

* Disallow:

To block the indexing of all contents, both pages, and posts with the robots.txt file:

Hide-WordPress-Post-Page-From-Google

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.

How to hide WordPress pages or articles from search engines via the All in on 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.

The bottom line on how to avoid indexing 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!

 

You Might Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *