• Resolved James Morton

    (@stylishjm)


    We have developed a bespoke multilingual solution for a client, which prepends languages to permalinks based on rewrite rules and query vars. Languages are simple custom fields that are displayed in place of normal English content when the query var is detected – basically, there are no separate pages for different languages, it is locale-adaptive.

    We have the lang HTML attribute, HREFLangs and WordPress locale working just fine, it is just the Canonical URL generated by The SEO Framework left before we can set live for international SEO purposes.

    We have two options

    1 – We completely disable The SEO Framework’s generation of canonical URLS site-wide, and handle this ourselves (probably easier for us)

    2 – We use a filter to alter the Canonical URL generated by The SEO Framework.

    Can you please advise:

    For #1, how do we disable just canonical URL generation site-wide?

    For #2, are there any hooks that we can use to modify the canonical URL generated by your plugin? I looked through the docs but couldn’t find anything.

    • This topic was modified 2 years, 7 months ago by James Morton.
Viewing 1 replies (of 1 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    #2: TSF relies on Core option home (Core filters home_url or post_link) to generate canonical URLs. The high-level filter get_canonical_url also works for most queries, and I suggest using that if the other two yield unexpected results.

    If you make your implementation work with WordPress’s intricacies, it should work with The SEO Framework (unless I have done something wrong).

    Without a canonical URL, you practically waive all protection TSF provides against bad backlinks and Google’s inexorable crawling of non-links. So I recommend seeking how to make the links work as intended first.

    #1: If you cannot make the URL work for any reason, return an empty string to the_seo_framework_rel_canonical_output, and the canonical URL will vanish. the_seo_framework_ogurl_output should retrieve the same treatment; otherwise, the og:url will redirect Facebook to a non-existing page when someone shares a link on their platform.

    I hope this helps ?? Cheers!

Viewing 1 replies (of 1 total)
  • The topic ‘Programmatically alter Canonical URLS’ is closed to new replies.