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

Last update: 13 July, 2018

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.

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.

How to Change the News Sitemap URL

This guide is written for advanced users and developers. Looking for a web developer to customize our plugin? We highly recommend checking out Code Poet as they have a great list of available freelance WordPress developers.

  • Disable all sitemaps by unchecking the sitemap box shown in this article.
  • Add the following to your functions.php file.
<br />
<?php
/* Change Yoast News sitemap when custom post news conflicts */
function wpseo_change_news_sitemap() { return "google_news"; }
add_filter('wpseo_news_sitemap_name', 'wpseo_change_news_sitemap');
?><br />

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

Was this article helpful? ·