Hello,
We apologize for the issue you are facing with adding your specific URL to the Rank Math sitemap. To include a custom URL like your Google AMP Web Story in the sitemap, you can follow these steps:
- Go to Rank Math Dashboard: Navigate to the Rank Math settings in your WordPress dashboard.
- Sitemap Settings: Click on the Sitemap Settings option.
- Add Custom URL: In the sitemap settings, you should find an option to add custom URLs. Here, you can manually enter your AMP Web Story URL:
`https://rankmath.com/kb/add-sitemaps-to-robots-txt/
- Save Changes: After adding the URL, make sure to save your changes.
If you do not see an option to add custom URLs directly in the sitemap settings, you may need to use a filter or hook in your theme’s functions.php file to programmatically add the URL to the sitemap. Unfortunately, this requires some coding knowledge.
For more detailed guidance on how to manage sitemaps with Rank Math, you can refer to our knowledge base article on How to Add Sitemaps to Robots.txt.
If you need further assistance or if this does not resolve your issue, please reply to this ticket, and a human agent from the Rank Math Support team will be happy to assist you further.
Thank you for raising this concern!
Hello,
You can use and modify the following filter on your website to add the URL to your sitemap:
/**
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() {
return '<url>
<loc>https://rankmath.com/some-custom-url/</loc>
<lastmod>2020-06-10T20:20:20+00:00</lastmod>
</url>';
});
Please make sure to change {$type}_content
with your post type. For example, if you want to add the URL to your post sitemap, then you use post_content
.
Here’s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/
Hope that helps and please don’t hesitate to let us know if you have any other questions.
Â
Thank you.
Thank you, Rakibuzzaman Siam.
I used the code above and it works for one URL. How do I modify the code to allow for several URLs? I’m guessing I’ll have to add (array) to the code but I’m not sure and I don’t want to break my website.
Also, I noticed that for the one URL added to the sitemap, that the priority is set at 0. How can I change that? Thank you for your assistance.
Hello,
You can follow the pattern on how to add more URLs with this filter:
/**
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() {
return '<url>
<loc>https://rankmath.com/some-custom-url/</loc>
<lastmod>2020-06-10T20:20:20+00:00</lastmod>
</url>
<url>
<loc>https://rankmath.com/second-url/</loc>
<lastmod>2020-06-10T20:20:20+00:00</lastmod>
</url>';
});
Also, please note that we do not have the option to set <priority>
and <changefreq>
values in sitemaps as they are no longer needed or required when creating sitemaps.
Looking forward to helping you.
Thank you. It worked. I appreciate you!
Hello,
We are super happy that this resolved your issue.
If you have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.
Thank you.