Hello,
Thank you for contacting Rank Math today.
This feature is not available but you can add some custom code to fetch the posts and add them to the sitemap. Please take a look at the example below for some guidance. This code should go to your theme’s functions.php file:
/**
* 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.
*/
add_action( 'rank_math/sitemap/{$type}_content', function() {
});
function rank_math_add_custom_dynamic_url( $urls ) {
$urls .= '
http://www.mysite.com/dynamic-category1/
2019-02-22T18:02:24+00:00
';
$urls .= '
http://www.mysite.com/dynamic-category2/
2019-02-22T18:02:24+00:00
';
return $urls;
}
I hope this info helps. Thank you.
​​​​​​
Hi Micheal,
Thanks for addressing me to this hook.
I had to modify it a bit, the sample above just echos the string to the xml but not formatted.
it should be like this:
$urls .= "<url>
<loc>http://www.mysite.com/dynamic-category2/</loc>
<lastmod>2019-02-22T18:02:24+00:00</lastmod>
</url>";
Its working for me now, so thanks!
it would be great if you could add a filter to the query that builds the sitemap.
Regards,
Yaniv
Hi Yaniv,
Thanks for the follow up.
I am glad that you were able to make this work 🙂
Don’t hesitate to contact us should any other issues come up.