Hello @ahhhaweb
Thank you for contacting the support.
You can use the following filter to add links to the required sitemap type:
/**
* Filter to add extra URLs to the XML sitemap by type.
*
* Only runs for the first page, not on all.
*
* @param string $content String content to add, defaults to empty.
*/
if ( 1 === $current_page ) {
$xml .= $this->do_filter( "sitemap/{$type}_content", '' );
}
If you want to add it to the category taxonomy sitemap you need to do try the following filter:
add_action( 'rank_math/sitemap/category_content', 'rank_math_add_custom_dynamic_url' );
function rank_math_add_custom_dynamic_url() {
$urls = '';
$urls .= '<url>
<loc>http://www.mysite.com/dynamic-category1/</loc>
<lastmod>2019-02-22T18:02:24+00:00</lastmod>
</url>';
$urls .= '<url>
<loc>http://www.mysite.com/dynamic-category2/</loc>
<lastmod>2019-02-22T18:02:24+00:00</lastmod>
</url>';
return $urls;
}
Please let us know if that helps. Thank you.
Thanks for the great support! Providing actual code is phenomenal! I tried adding it to the class-sitemap.php file but that had no effect. A new site map just generated and it looks pretty much the same.
To be clear, what I need is for the site map generator to crawl and follow my href anchor links. The way my site works is a normal WordPress page template will call an API that returns a product list with hrefs that will generate product listing pages that will contain hrefs that generate product detail pages which contain prices and add-to-cart buttons. I need those product detail pages with the prices added into the sitemap so I can encourage Google to index them and pick up the structured data product tags I implemented.
Thanks!!
Hello @ahhhaweb
Can you please turn off the Sitemap’s caching and then test?
https://rankmath.com/kb/filters-hooks-api-developer/#enable-disable-sitemap-cache
Please do flush the permalinks cache by simply saving the settings of the Sitemaps and the Permalinks.
Let us know if that helped. Thank you.
Hello @ahhhaweb
Assuming you got it sorted, we are closing this topic.
If you need any further assistance, please feel free to open a new support topic and we will be more than happy to assist.
Thank you.