News sitemap doesn’t work when I have Custom Post Type ‘News’

Note: The default Yoast-News-Sitemap will only show if you have a published news article within the past 48 hours. You may need to publish a post-type in order to generate that sitemap.

Yoast SEO: News will automatically detect a naming collision and change the news sitemap name. Please go to Admin > SEO > News SEO and click the ‘XML News sitemap’ link to get the correct sitemap URL.

If you prefer to give your news sitemap a custom name, please use the developer filter discussed below.

How to Change the News Sitemap URL

  1. Disable the sitemap feature.

    Disable all sitemaps by following the steps in this article.

  2. Add the filter in your theme’s functions.php file.

    See the example code below.

  3. Enable the sitemap feature.

    Enable all sitemaps by following the steps in this article.

This will create two sitemaps; one for the news custom post type and one specifically formatted to meet Google News guidelines.

News Post Type = www.example.com/news-sitemap.xml
Google News Format = www.example.com/google_news-sitemap.xml

You or your developer can use a filter to change the name of the Yoast SEO news sitemap. An example of how to use this filter is below.

/* Change Yoast News sitemap when custom post news conflicts */
function wpseo_change_news_sitemap() {
     return "google_news";
}
add_filter('Yoast\WP\News\sitemap_name', 'wpseo_change_news_sitemap');

Did this article answer your question?

Thanks for your feedback!

Get free SEO tips!