How to Customize the Sitemap Index

Last update: 11 July, 2018

The sitemap index includes links to a variety of sub-sitemaps for posts, pages, authors, categories, tags, and other taxonomies. The sitemap index can be customized under SEO > Search Appearance. Removing a post type from the search results will also remove them from the sitemap. Showing them in the search results will show them in the sitemap. Add or remove items as needed.

  • Log in to your WordPress website. When you’re logged in, you will be in your ‘Dashboard’. On the left-hand side, you will see a menu. In that menu, click on ‘SEO’.
  • The ‘SEO’ settings will expand providing you additional options. Click on ‘Search Appearance’.
  • Click on the appropriate tab to add or remove certain post types from the search results. Removing a post type from the search results will also remove them from the sitemap. Add or remove items as needed.
  • Click ‘Save Changes’.

Content Types

Posts, pages, and other custom post types can be customized under the ‘Content Types’ tab. Some content types are not added publicly and thus do not appear for exclusion. When this occurs, the post type can either be made public or manually excluded using a developer filter.

You can also remove individual post types from the sitemap by marking them with a noindex tag. Use this guide if you are not sure how to do that: How do I Noindex Urls?

Media

When you upload an image, WordPress automatically creates a post of the type “attachment” in the database, and the corresponding URL for that. It calls this the “media” post type. Learn more here.

Taxonomies

Categories, tags, and other taxonomies can be customized under the ‘Taxonomies’ tab. Some taxonomies are not added publicly and thus do not appear for exclusion. When this occurs, the taxonomy can either be made public or manually excluded using a developer filter.

Archives – Author Sitemap

Our plugin creates a sitemap that lists the author pages. Learn more about customizing the author sitemap for single author websites or multiple author websites.

Other Sitemaps

Video Sitemap

Our Video SEO plugin sitemap can be customized under Admin > SEO > Video SEO.

News Sitemap

Our News SEO plugin sitemap can be customized under Admin > SEO > News SEO.

Local Sitemap

Our Local SEO plugin sitemap is generated based on the location data entered into the plugin.

Non-Yoast Plugin Sitemaps

You can add non-Yoast sitemaps to the index. Please read this article for more information.

Developer Filters

Below are a few examples using the developer filters in your functions.php file to customize the sitemaps. If you are not familiar with implementing code in WordPress, we highly recommend checking out Code Poet as they have a great list of available freelance WordPress developers.

Content Types

Filter: wpseo_sitemap_exclude_post_type

/* Exclude One Content Type From Yoast SEO Sitemap */
function sitemap_exclude_post_type( $value, $post_type ) {
if ( $post_type == 'post_type_slug' ) return true;
}
add_filter( 'wpseo_sitemap_exclude_post_type', 'sitemap_exclude_post_type', 10, 2 );
/* Exclude Multiple Content Types From Yoast SEO Sitemap */
add_filter( 'wpseo_sitemap_exclude_post_type', 'sitemap_exclude_post_type', 10, 2 );
function sitemap_exclude_post_type( $value, $post_type ) {
$post_type_to_exclude = array('post_type_slug1','post_type_slug2', 'post_type_slug3');
if( in_array( $post_type, $post_type_to_exclude ) ) return true;
}

Taxonomies

Filter: wpseo_sitemap_exclude_taxonomy

/* Exclude One Taxonomy From Yoast SEO Sitemap */
function sitemap_exclude_taxonomy( $value, $taxonomy ) {
if ( $taxonomy == 'taxonomy_slug' ) return true;
}
add_filter( 'wpseo_sitemap_exclude_taxonomy', 'sitemap_exclude_taxonomy', 10, 2 );
/* Exclude Multiple Taxonomies From Yoast SEO Sitemap */
add_filter( 'wpseo_sitemap_exclude_taxonomy', 'sitemap_exclude_taxonomy', 10, 2 );
function sitemap_exclude_taxonomy( $value, $taxonomy ) {
$taxonomy_to_exclude = array('taxonomy_slug1','taxonomy_slug2', 'taxonomy_slug3');
if( in_array( $taxonomy, $taxonomy_to_exclude ) ) return true;
}

Authors

Filter: wpseo_sitemap_exclude_author

Was this article helpful? ·