• Resolved wemnael

    (@wemnael)


    Hello,

    I use a custom header theme for my pages and have a special canonical tag there. So I end up with 2 canonical tags, one from my costum header template and one from Yoast SEO. How can I get rid of the last only when using my theme? Thank you. So I still want to use yoast canonical but not when showing a certain header template.

    • This topic was modified 6 years, 5 months ago by wemnael.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Michael Ti?a

    (@mikes41720)

    You can refer to this article if you want to modify the canonical URL output from the Yoast SEO plugin — https://kb.yoast.com/kb/canonical-urls-in-wordpress-seo/

    Thread Starter wemnael

    (@wemnael)

    I’ve read that article, but I have 1000+ URL that need to be updated so I prefer just to change header template for my stores pages… And this cause duplicate canonical… Thank you again !

    Thread Starter wemnael

    (@wemnael)

    It worked by adding this function in functions.php : SO I excluded only for wp store posts.

    add_filter( 'wpseo_canonical', 'yoast_remove_canonical_items' );
    function yoast_remove_canonical_items( $canonical ) {
      if ( is_singular ( 'wpsl_stores' ) ) {
        return false;
      }
      /* Use a second if statement here when needed */
    	return $canonical; /* Do not remove this line */
    }
    • This reply was modified 6 years, 5 months ago by wemnael.
    • This reply was modified 6 years, 5 months ago by wemnael.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Remove canonical tag from certain theme’ is closed to new replies.