Back to Community

How to Exclude Tags, Categories, and Other Content from Your XML Sitemap

12 threads Sep 7, 2025 PluginXml sitemap generator for google

Content

A common challenge for WordPress users of the 'XML Sitemap Generator for Google' plugin is managing exactly which content appears in their sitemap. Many users wish to exclude specific items like tags, certain categories, or posts marked "noindex" to prevent search engines from crawling them. Based on community discussions, here’s a breakdown of the problem and the most common solutions.

The Core Problem

The plugin's primary interface provides a straightforward way to exclude posts and categories. However, users frequently need to exclude other types of content, such as:

  • Specific Tags
  • Posts in the "Uncategorized" or "No Category" category
  • Posts marked as "noindex" by a separate SEO plugin
  • Media items like logos
  • Content based on custom field values

This limitation often leads to these items appearing in the sitemap, which can cause errors in Google Search Console if the sitemap is empty or contains content that shouldn't be indexed.

Common Solutions and Workarounds

1. Using Available Plugin Settings

First, check the plugin's settings page under XML-Sitemap > Posts. Here you can:

  • Exclude specific individual posts or pages by their ID.
  • Exclude entire categories.

Important Note: Some users have reported that excluding a category can sometimes result in an empty sitemap file if no other posts were modified recently, which Google Search Console will flag as an error. If this happens, you may need to adjust your exclusion rules.

2. For Advanced Control: Using Hooks and Filters

The most powerful and flexible way to gain fine-grained control over your sitemap content is by using WordPress hooks and filters. The 'XML Sitemap Generator for Google' team suggests this method for excluding taxonomies like tags or for creating complex rules based on custom fields.

Example for Excluding Tags:
Since the settings interface does not include a field for tags, you would need to add a custom code snippet to your theme's `functions.php` file or a custom plugin. The specific hook needed for this can typically be found in the plugin's official documentation or FAQ.

Example for Excluding by Custom Field:
Similarly, to exclude a post if a custom field (e.g., `advertiser`) has a specific value (e.g., `excluded`), you would need to implement a custom filter. The plugin's documentation is the best place to find the correct filter names and examples.

3. Addressing "Noindex" and Third-Party SEO Plugins

There is a known scenario where a post is set to "noindex" in a plugin like All in One SEO Pack but still appears in the XML sitemap. This happens because the two plugins operate independently.

Potential Solutions:

  • Use the sitemap functionality provided by your SEO plugin instead, as it is designed to automatically respect its own "noindex" settings.
  • Implement a custom filter to query the post's meta data for the `_aioseop_noindex` field (or the equivalent from your SEO plugin) and conditionally exclude it from the sitemap.

Conclusion

While the 'XML Sitemap Generator for Google' plugin offers essential exclusion settings, achieving more advanced control requires using custom code via filters and hooks. For users who are not comfortable with code, checking the plugin's detailed documentation for specific filter examples is highly recommended. The community often shares solutions there for common exclusion scenarios.