Support » Plugin: The SEO Framework » How to disable canonical URL generation on specific pages

  • Resolved olivermerk

    (@olivermerk)


    Is there a simple way to disable the generation of a canonical URL on specific pages?

    We have a self-programmed product plugin, that is embedded as a shortcode on an extra page and outputs all of our products within this page. TSF thus generates for every product the same canonical URL, so we have problems with Google indexing.

    <link rel="canonical" href="https://www.pecon.biz/products/product/" />

    Is there a simple “magic code” I could enter into the Canonical URL field of this product page to disable the generation on this page? So I could create the canonical URL by myself in the product plugin code?

    Best regards,
    Oliver

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hi Oliver,

    I recommend filtering the canonical URL in WordPress’ function wp_get_canonical_url():
    https://developer.wordpress.org/reference/functions/wp_get_canonical_url/

    You’ll want to filter get_canonical_url. It will then work cross-platform.

    Alternatively, this filter will do the trick:

    add_filter( 'the_seo_framework_rel_canonical_output', '__return_empty_string' );
    

    I hope this helps! Cheers 🙂

    olivermerk

    (@olivermerk)

    Hi Sybre,

    thanks, that hint indeed helped me to set up my own filter for canonical URL.

    Cheers
    Olli

    • This reply was modified 1 year ago by  olivermerk.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to disable canonical URL generation on specific pages’ is closed to new replies.