How do I get WordPress URL rewrites into Sitemap?

Consider the two following custom post types:

  • Museums
  • Bakeries

With one shared taxonomy:

  • Region

I'm using rewrite rules to improve the URL structure, so I can serve pages to visitors such as:

Here are the rewrite rules:

function my_url_rewrite_rule() {
    add_rewrite_rule( '^museums/([^/]+)/?$',
            'index.php?taxonomy=regionpost_type=museumsterm=$matches[1]', 'top' );

    add_rewrite_rule( '^museums/([^/]+)/page/([0-9]+)?$',
            'index.php?post_type=museumsgenre=$matches[1]paged=$matches[2]', 'top' );

    add_rewrite_rule( '^bakeries/([^/]+)/?$',
            'index.php?taxonomy=regionpost_type=bakeriesterm=$matches[1]', 'top' );

    add_rewrite_rule( '^bakeries/([^/]+)/page/([0-9]+)?$',
            'index.php?post_type=bakeriesgenre=$matches[1]paged=$matches[2]', 'top' );
}
add_action( 'init', 'my_url_rewrite_rule', 10, 0 );

I have set up my templates and everything works fine, with one exception: I can't get the following type of pages into my sitemap:

.. And every other combination of url+post_type+taxonomy. I can access the URLs and have working templates, but I just can't get the sitemap to understand the new structure. This is not surprising as I'm bypassing the default url structure of Wordpress. But how can I proceed to get them into the sitemap?

I'm using SEOPress (Pro), but I've also tried with Yoast.

Thanks!

Topic sitemap custom-post-type-archives plugin-wp-seo-yoast rewrite-rules custom-taxonomy Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.