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

If you have the Custom Post Type News, your sitemap may work differently than expected. 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 News SEO will automatically detect a naming collision and change the news sitemap name. You can find the correct sitemap URL under Local SEO.

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

How to change the news sitemap URL with a developer filter

  1. Disable all sitemaps

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

    /* 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');

  3. Enable all sitemaps

  4. You have created one News custom post type sitemap and a second sitemap formatted for Google News guidelines

    The News custom post sitemap will look like www.example.com/news-sitemap.xml; the Google News format will look like www.example.com/google_news-sitemap.xml.

Did this article answer your question?

Thanks for your feedback!

Leave feedback

Did this article answer your question?

Thanks for your feedback!

Still having issues?

Try searching for your issue below