Hello 9degrees,
Thanks for reaching out about using the wpseo_canonical filter.
I assume you want to change the canonical URLs of your pages/posts in bulk; is this correct? The filter can change the canonical URL that Yoast SEO generated for a URL programmatically. We also have more documentation on managing canonical URLs in Yoast SEO available at our developer portal at the following URL: https://developer.yoast.com/features/seo-tags/canonical-urls/overview/
Also, if your current canonical URL output is wrong, it could be that the Indexables tables and migrations have the wrong path. So, you’ll need to reset the Yoast SEO Indexables tables and migrations by following the steps given below:
– Install and activate Yoast Test Helper plugin;
– Go to Tools → Yoast Test → Yoast SEO → Reset indexables tables & migrations options to reset it;
– Run SEO data optimization from the SEO → Tools page.
Do let us know how it goes.
Hi Maybellyne,
I don’t think you understand our issue. Your plugin offers a filter (wpseo_canonical) which developers can use to modify the output of the canonical. The problem is this filter is not being used whenever your website is on no-index, see the following code:
if ( \in_array( ‘noindex’, $this->presentation->robots, true ) ) {
return ”;
}
return \urldecode( (string) \trim( \apply_filters( ‘wpseo_canonical’, $this->presentation->canonical, $this->presentation ) ) );
Our development environments are always on no-index, to make sure they won’t end up in Google. I have know solved this issue by temporary changing the no-index setting so I could test out our modification. However I do believe this is a fault in the code, which you might want to address.
Hey @9degrees,
Apologies for the late response.
Based on your provided information, it indeed sounds like something we could improve. We’re actively using the bug/feature requests tracking on our GitHub repository, so your best next step would be to create a new issue for our developers here. They will be able to see if they see fit for the issue.
You will need an account to create a new issue. Please provide as much information about the issue, including the URL to this conversation. This guide will help you submit a complete report which may result in a faster resolution.
Thank you.