How to Keep a Page from Being Visible in WordPress

Sometimes you need to have a page on your WordPress website that people can’t find by searching. But you want the page to be publicly accessible.


Maybe you have a product or service that you just want to offer to a few special customers. Or a special event that you only want to invite certain people to. Maybe you’ve recorded a video that you want to share with a few people.

The page needs to be easy for people to get to, so you really don’t want to require a password. But at the same time, you don’t want just anyone to stumble across it when they search for things on Google. And when someone visits your website and uses the built-in search feature, you don’t want it to show up in those results either.

How To Set Up a Hidden Page?

I’ll show you how to set this up. This approach will work with WordPress posts or pages.

The first step is to keep the page out of Google’s index.

You do this by setting the NOINDEX tag. If you’re using the Yoast plugin, which I highly recommend, follow these steps.

  1. Edit the page in WordPress.
  2. Scroll down to the Yoast SEO section of the page editor.
  3. Click Advanced.
  4. Where it says “Allow search engines to show this Page in search results?” select “No.”
  5. Where it says “Should search engines follow links on this Page?” also select “No.” This isn’t absolutely essential. But if you don’t want the special page to be indexed, you probably also don’t want Google to follow links from that page when building its index.
  6. Click “Update” to save your changes.

That’s it for Google.¬†Following these steps will hide the page from Google’s index.

But the page will still show up if someone does an internal, on-site search using the search feature that is built into WordPress websites. Also note that most WordPress sites have internal search enabled, even if you don’t have a search feature in your header or footer menu or anywhere obvious on your website.

Hiding the Page in On-Site Search

To keep your special page out of the internal search results, install the WordPress plugin Search Exclude. Update: the Search Exclude plugin used to be an easy way to keep pages out of the WordPress search, but as of August 30, 2019, it is temporarily being removed from the plugin repository on See the support forum for slightly more information.

Fortunately, there’s another way. It requires a little bit of code and is documented¬†more detail on

In short, find out what the post ID (or page ID) is for the particular page that you want to hide.

Next, go into the functions.php file in your child theme and paste in the following code (adapted from Modify the list of numbers in the array referenced in the $query->set command so that it contains only the page or post IDs of the pages you want to suppress.

function r20190902_search_filter( $query ) {
   if ( $query->is_search && $query->is_main_query() ) {
      $query->set( 'post__not_in', array( 236, 237 ) );
add_action( 'pre_get_posts', 'r20190902_search_filter' );

The code above hides posts 236 and 237. Replace those numbers with whatever post numbers you want.

Protecting Content with a Password

Password protecting some of your content, such as a page, a category or products in an online store is also useful. See this recently published article from the folks at Beaver Builder for more information on ways to password protect content on a WordPress website.