Easy Ways to Exclude Pages from XML Sitemap in WordPress

Not every page on your WordPress site needs to show up in your XML sitemap—some just aren’t worth Google’s attention. Maybe it’s a thank-you page, a staging URL, or a random test post from last year. Whatever the case, cluttering your sitemap with low-value pages can confuse search engines and dilute your SEO efforts. Luckily, there’s no need to wrestle with code or install bloated plugins. You’ve got options—simple ones—to exclude pages from xml sitemap without breaking anything. 

Use an SEO Plugin Like Squirrly SEO

A powerful SEO plugin like Squirrly SEO makes it simple to exclude pages from your XML sitemap files without touching any code. It includes built-in settings that give you full control over what appears in your sitemap. No need to hire a developer or dig into theme files.

In Squirrly SEO, head over to the page or post you want to exclude. Scroll down to the SEO Settings section inside the Squirrly panel. Click on Advanced Settings, then look for the option that says “Allow Search Engines to Index This Page.” Set it to “No.” Once that’s done, Squirrly SEO will automatically remove the page from your sitemap as well.

If you need to exclude multiple pages or entire post types—like templates, thank-you pages, or ad landing pages—Squirrly SEO also offers bulk exclusion options through its global settings. You can find these controls under Sitemap Settings in the plugin’s dashboard.

Using Squirrly SEO cuts down the time spent managing technical SEO tasks manually. It lets you focus more on strategy and content instead of fiddling with backend files every time a new page needs to stay out of search results.

The best part? These changes don’t affect how visitors see your site—they only control how search engines read it. That means no broken links, no 404s—just smarter control over what Google indexes and what stays behind the scenes where it belongs.

Exclude Pages from XML Sitemap Using Code

If plugins aren’t your thing and you prefer getting your hands dirty, this method is for you. WordPress lets you tweak things directly through the `functions.php` file.

First, head to your theme folder. You can do this via FTP or through the WordPress dashboard under Appearance > Theme File Editor. Open the `functions.php` file of your active theme — not a child theme? Might want to fix that first unless you enjoy surprises during updates.

Now, paste in this code at the end of the file:

“`php

add_filter( ‘wp_sitemaps_posts_query_args’, function( $args, $post_type ) {

if ( ‘page’ === $post_type ) {

$args[‘post__not_in’] = array( 42, 76 ); // Replace with your page IDs

}

return $args;

}, 10, 2 );

“`

This tells WordPress: “Hey, ignore these specific pages when building my sitemap.” You just need to swap out those numbers with the actual page IDs you want gone. Not sure how to find them? Edit any page in WordPress and check the URL — it’ll look like `post=76`.

Prefer working with posts instead of pages? Change `’page’` to `’post’`. Want both gone? Duplicate that block and adjust accordingly.

This approach doesn’t require updates or third-party tools. It gives full control over which content appears in search engine indexes. Plus, it’s one less plugin slowing down your site or causing conflicts later on.

Remember—always back up before editing core files. One missing semicolon and things get weird fast.

Using code keeps things lean and direct while avoiding extra bloat. It’s ideal for freelancers who manage multiple sites and want quick results without plugin overhead.

Install a Dedicated Sitemap Management Plugin

Tired of digging through code or messing with functions.php just to keep that one page out of your sitemap? You’re not alone. A dedicated sitemap plugin can save you time and prevent headaches. These tools let you pick which pages show up in the sitemap, and more importantly, which don’t.

Several plugins do this job well. One example is XML Sitemap & Google News. Another is Rank Math, which includes built-in options for sitemap control. With these tools, there’s no need to edit files manually or install extra add-ons just to manage visibility.

Once installed, most plugins give you a simple interface. You’ll often get checkboxes next to each post type or taxonomy. Want to hide outdated landing pages? Just uncheck them. Need to block certain custom post types from crawling? That’s two clicks away.

Some plugins even offer filters based on categories or tags. This helps when working with large sites where excluding individual URLs becomes inefficient fast. You can apply rules across entire groups instead of doing it page by page.

This method also keeps things tidy if you’re juggling multiple languages or country-specific versions of content. Instead of creating separate sitemaps manually, you can automate inclusion and exclusion using plugin settings.

Using a plugin also reduces the chance of errors in your robots.txt file or accidental indexing issues. It gives peace of mind without needing deep technical knowledge.

If your goal is to exclude pages from XML sitemap quickly and cleanly, this route makes sense—especially when managing many clients or complex sites where manual updates just aren’t practical anymore.

No need for guesswork here—just install, click around a bit, and move on with your day (and maybe finally fix that broken redirect you’ve been avoiding).

Set Pages to “Noindex” and Disable Sitemap Inclusion

Some pages just don’t need to show up in search results. Think of thank-you pages, internal instructions, or those duplicate landing pages used for A/B testing. These types of content can clutter your sitemap and confuse indexing. Luckily, most SEO plugins in WordPress let you mark a page as “noindex” and often handle the rest for you.

Using an SEO plugin like Yoast or Rank Math makes this simple. When editing a page or post, scroll down to the plugin’s settings box. There’s usually an option labeled something like “Allow search engines to show this Page in search results?” Flip that setting to “No.” That tells Google not to index it.

Now here’s where it gets handy — many plugins automatically remove noindexed pages from the sitemap too. So once you set a page as noindex, it often disappears from the XML file without extra effort on your part.

Still want full control? Some plugins give you separate checkboxes: one for noindexing and another for excluding from sitemaps manually. Use both if needed — especially helpful when you’re dealing with complex multilingual setups or region-specific content that isn’t relevant globally.

To exclude pages from xml sitemap without relying only on automation, double-check your plugin’s settings under its sitemap section. You might find options where you can untick specific post types or custom URLs so they stay out of the file entirely.

This method is fast, clean, and keeps your sitemap focused only on what matters — useful when reporting performance across countries or trying to track what’s actually being indexed versus what isn’t worth crawling at all.

Smart Sitemap Tweaks for Sharper SEO Control

Now that you’ve explored multiple ways to exclude pages from XML sitemap in WordPress, it’s clear that flexibility is key. Whether you’re using powerhouse plugins like Yoast or Rank Math, tweaking code manually, or installing a dedicated sitemap tool, each method gives you more control over what search engines see. Setting pages to “noindex” and removing them from your sitemap ensures your SEO strategy stays focused and clutter-free. The right approach depends on your workflow—but with these tools in hand, managing visibility across markets just got a whole lot easier (and smarter).

Share the Post:
Share the Post:

Dominate Search Engine Rankings

with AI and the Full Force of SEO

Related Posts