Hello,
We apologize for the issue you are facing with including your blog directory in the sitemap generated by Rank Math. Unfortunately, the context does not provide specific instructions on how to include a subdirectory in the main site’s sitemap using Rank Math.
However, we recommend that you reply to this ticket with your request, and a human agent from the Rank Math Support team will be able to assist you further with detailed instructions.
Thank you for raising this concern, and we appreciate your understanding.
Looking forward to helping you resolve this!
Hello,
If you want to include the blog sitemap in your main sitemap, you may need to use and customize this filter:
add_filter( 'rank_math/sitemap/index', function( $xml ) {
$xml .= '
<sitemap>
<loc>https://subdirectory.com/blog/sitemap-index.xml</loc>
<lastmod>2024-12-02T08:02:27-05:00</lastmod>
</sitemap>
return $xml;
}, 11 );
If you’re not sure how to add this code, you can follow this guide:
https://rankmath.com/kb/wordpress-hooks-actions-filters/
Once done, please follow these steps to flush your sitemap cache:
1. Flush the Sitemap cache by following this video screencast:
https://i.rankmath.com/pipRDp
2. Exclude the Sitemap files of the Rank Math plugin in your caching plugin. The cache could be via a plugin or from the server. For plugins or Cloudflare, please follow this article:
https://rankmath.com/kb/exclude-sitemaps-from-caching/
Hope that helps.
Thanks Reinelle, should I add this in function.php?
Hello,
Yes, this should be included in your theme’s functions.php file.
Also, please note that you might need to make some modifications to the filter to include the correct sitemaps from the sub-folder installation.
Don’t hesitate to get in touch if you have any other questions.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.