For various reasons, I've been asked to duplicate a wordpress blog across multiple subdomains. Obviously, this will cause duplicate content issues, which I hope to mitigate with the use of a canonical tag, pointing back to a single sub-domain (www).
I'm using Yoast SEO on the site however. This auto generates the canonical tag - and appears to use whichever sub-domain I'm on at the time. Presumably it's picking this up from the WP_SITEURL setting or similar, but I've had to modify this to allow the multiple sub-domains in the first place.
Is there any way that I can force Yoast SEO to use a single sub-domain for all canonical URLs? I still need all links on the site and general functionality to make use of the other sub-domains - whichever it's currently on - but the canonical should always point back to a single sub-domain.
Please note: redirection is not an option.
I figure the best way to do this is with the Yoast SEO API, but I'm unfamiliar with it. I think I need to adjust the following to include my desired sub-domain, but I'm unsure as to the syntax to get the rest of the generated URL in there.
add_filter( 'wpseo_canonical', 'http://www.' );