How do I remove pages from my WordPress sitemap — 5 methods

How Do I Remove Pages from My WordPress Sitemap ?

How Do I Remove Pages from My WordPress Sitemap?

To remove pages from WordPress sitemap, you have five options: the Protect WordPress Pages and Posts plugin by Prevent Direct Access, Yoast SEO, All in One SEO, the Google XML Sitemap plugin, or editing your functions.php file directly.

Not every page on your WordPress site should be indexed by Google. Private content, broken URLs, duplicate pages, and certificate pages are common examples of content you want out of your sitemap — and out of search results entirely.

🎥 Watch the Full Tutorial

See each method demonstrated step by step in the video below.

Subscribe for more WordPress security tutorials that actually work.

🔍 Why You Need to Remove Pages from WordPress Sitemap

Your XML sitemap tells Google which pages to crawl and index. That means any page listed in your sitemap is a page Google can find, rank, and show publicly. Learn more about how the WordPress built-in sitemap works and what it includes by default.

If private or sensitive pages appear in your sitemap, they are exposed — even without a direct link. The need to remove pages from WordPress sitemap becomes critical when dealing with client portals, private downloads, or certificate pages. According to Google Search Central, the most reliable way to prevent indexing is to use a noindex directive or remove the page from your sitemap entirely.

In other words: if a page is in your sitemap, it is visible to search engines. If it should not be public, it should not be in your sitemap.

✅ Method 1: Protect WordPress Pages and Posts Plugin by Prevent Direct Access

The first way to remove pages from WordPress sitemap is using the Protect WordPress Pages and Posts plugin by Prevent Direct Access — the most complete option because it removes the page from your sitemap and protects it at the same time. No code required.

Before protecting a page, you can confirm the problem: anyone with the URL can access that page right now. No login required. No protection. Fully indexed by Google.

One-Time Global Setup

After installing the plugin, go to Content Protection in your WordPress admin and configure the following:

  • Set Post Type Protection to Pages and Posts
  • Set the No Access page to 404 error page
  • Enable both toggles under Hide Protected Content — one for posts, one for pages
  • For each toggle, enable: Front page, Category pages, Archives, and Search results
  • Click Save Changes

This is a one-time global setup. You only do this once.

Protecting an Individual Page

  1. Go to your Pages list
  2. Find the page you want to remove from the sitemap
  3. Click Configure protection next to that page
  4. The plugin shows the page is unprotected — click Protect this page
  5. A green Protected badge confirms the page is now protected

What Happens After Protection

Go back to your XML sitemap and reload it. The page is completely removed from the sitemap.

And if anyone tries to access that URL directly, they get a 404 error.

That means the page is protected and excluded from your WordPress sitemap in one single step — simultaneously.

✅ Method 2: Yoast SEO Plugin

The second way to remove pages from WordPress sitemap is using the Yoast SEO plugin.

Exclude All Posts or Pages at Once

  1. Go to Yoast SEO → Settings
  2. Under Content Types, click Posts
  3. Turn off the toggle next to Show posts in search results
  4. Click Save Changes
  5. Repeat the same steps for Pages

Disabling this toggle means all posts or pages will be excluded from your XML sitemap automatically. That means Google will no longer index that content type.

Exclude a Single Page Individually

To exclude a single page, open it in the editor and scroll down to the Yoast SEO Advanced section at the bottom.

  • Set Allow search engines to show this content in search results to No
  • Optionally, set Should search engines follow links on this content to No
  • Save the page

That specific page is now excluded from your WordPress sitemap — without affecting the rest of your site.

✅ Method 3: Google XML Sitemap Plugin

The third way to remove pages from WordPress sitemap is using the Google XML Sitemap plugin.

This method works by excluding specific pages using their post IDs.

Step 1: Find Your Page IDs

Go to Posts or Pages, hover over the title, and look at the URL at the bottom of your browser. The number after post= is the ID. Collect all the IDs you need before you start.

Step 2: Add IDs to the Excluded Items Field

  1. Go to Settings → XML Sitemap
  2. Scroll down to the Excluded Items section
  3. In the Exclude posts field, type the page IDs separated by commas
  4. Scroll down and click Update options

Those pages are now excluded from your WordPress XML sitemap and will no longer be indexed by Google. For more details on how WordPress handles sitemaps natively, refer to the official WordPress Sitemap documentation.

This method is straightforward but requires manually copying each page ID. If you have multiple pages to exclude, collect all IDs before you start.

✅ Method 4: All in One SEO Plugin

The fourth way to remove pages from WordPress sitemap is using the All in One SEO plugin.

How to Exclude Content Types

  1. Go to All in One SEO → Search Appearance
  2. Click the Content Types tab
  3. Under Posts, set Show in Search Results to No
  4. Scroll down to Pages and do the same
  5. Click Save Changes

Setting this to No means those content types will be noindexed and excluded from your WordPress sitemap automatically.

This method removes entire content types from your sitemap at once. If you only need to exclude one specific page, All in One SEO also lets you do that from the individual page editor — through the Advanced settings at the bottom of the page, the same way Yoast SEO does it.

✅ Method 5: Edit Your functions.php File

The fifth way to remove pages from WordPress sitemap is by adding a code snippet to your functions.php file.

Before making any changes, always back up this file and save a copy to your local device.

How to Add the Code

  1. Go to Appearance → Theme File Editor
  2. In the list of theme files on the right, click functions.php
  3. Scroll to the very end of the file
  4. After the last line of code, add the following filter:
add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', function () {
  return array( 311, 322 );
} );

Replace 311 and 322 with your actual page IDs. Then click Update File to save.

Those pages are now excluded from your WordPress XML sitemap.

🧭 Which Method Should You Use to Remove Pages from WordPress Sitemap?

Here is a summary of all five ways to remove pages from WordPress sitemap:

  • Protect WordPress Pages and Posts plugin by Prevent Direct Access — removes the page from your sitemap and protects it at the same time
  • Yoast SEO — disable indexing globally per content type or individually per page
  • Google XML Sitemap plugin — exclude pages by entering their post IDs
  • All in One SEO — set entire content types to noindex from Search Appearance settings
  • functions.php file — add a code filter with specific page IDs

If you want one solution that handles everything in one step — the Prevent Direct Access plugin is the one. Once your sitemap is clean, you can also follow our guide on how to optimize your WordPress sitemap for better SEO results.