This is about to be released in the upcoming WordPress 5.5
@santosguillamot, now that our plugin is going to know if Frontity is being used in decoupled mode and the Frontity URL, it could add the filters for core sitemaps. Maybe also filters for other popular plugins, like Yoast.
EDIT: By the way, I donât know if the filter I proposed in the opening post is still valid.
Iâve been taking a look at it and it seems the filters you suggested in the opening post arenât available anymore. We can find the new filters in the announcement or the plugin description.
I thought wp_sitemaps_posts_pre_url_list could work similar to the ones you used, but after doing some tests I think the purpose is different and you donât have the $url_list at that point (youâll have to generate it yourself).
Not sure but maybe we could use the filter wp_sitemaps_posts_entry, but I havenât tested it yet. Iâll try to do it and keep you posted.
Iâve been taking a deeper look at that filters and I think itâs what we should use. Iâve tested them locally and it worked great. The logic is almost the same as the one Luis shared in the opening post, I just had to adapt it to these filters and I had to define the unparse_url() function. With this we can use the Sitemaps functionality and change the url to point to the Frontity domain. This is the code I was using:
Thank you very much for providing this example.
Have some questions on that:
I use a lot of custom taxonomies. Do you think i have to add_filter for all the sitemaps? See Screenshot
As you can see from the screenshot the sitemap on my side is generated by Yoast, but i also use WordPress 5.5.1 version. So do you think i have to use them as you described here?
If youâre using Yoast, I think the same filter should work for all the Post Types and for any url. And if you are using Yoast sitemap you should use this filter I mentioned. I think Yoast is overriding default WordPress sitemap so it shouldnât be a problem.
This is not part of Frontity, itâs part of your backend. You just have to specify in your robots.txt where your sitemap, adding a line like this one:
As you mentioned, it works well just changing to the yoast filter instead: add_filter('wpseo_sitemap_entry', 'change_urls');
What it does miss though is the front page url and the archive pages for custom post types.
Adding a page for the CPT archive would include it in âpage-sitemap.xmlâ though. Which can be a temporary solution. We would still be able to use the url as archive, if thatâs preferred.
Realizing that Yoast sitemaps does not include ACF images in the sitemap - as the ACF Content Analysis for Yoast SEO does not crawl the app domain. I guess the domain should be changed earlier than when its outputting the link URLs.
Maybe thereâs a better alternative than Yoastâs sitemaps, if they dont adjust their plugin more for going headless.
Hi !
I have generated my own sitemap.xml for different routes by using react-router-sitemap and now i want to open it in a route. e.g: https://staging.cashero.com/sitemap.xml
But itâs always giving me 404.
I have done this work many times in simple react websites. But first time, itâs creating issue only on frontity.
So, Can anyone please help me out on this issue ?
Thanks
I wanted Google to index my site, so i found this thread and read up on how to do it. I changed my frontity sitemap with the function in the thread, and the new sitemap works, but the link to the homepage does not change. I removed the âno indexâ setting in wordpress yesterday, and now Google has indexed my site. The problem is that is has indexed the wp site and the frontity site, and that the homepage is only indexed as the wp version. Is there another way to add a sitemap?
What we recommend right now it to use robots.txt to point to your WordPress sitemap, and filter the URLs of the sitemap to point to the Frontity domain.
I have not found a way to do this, but you donât have to. Google or any robot, doesnât care where your sitemap is hosted, as long as the domain is the same.
So for example if you have:
You can then in your robots.txt in website.com place: Sitemap: https://cms.website.com/wp-sitemap.xml
Actually it doesnât even have to be on the same domain, it can be anywhere, however if its on another domain you will have to rely on Google picking it up itself, as search console wonât allow you to submit a sitemap that is not on the same main domain.