This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function custom_canonical() { | |
if (isset($_SERVER['HTTP']) && $_SERVER['HTTP'] != 'off') { | |
return "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; | |
} else { | |
// Yoast SEO will use default canonical for HTTPS version site | |
} | |
} | |
add_filter( 'wpseo_canonical', 'custom_canonical' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="canonical" href="https://<?php echo $_SERVER['HTTP_HOST']; ?><?php echo parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ); ?>" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/ | |
/* Remove Yoast SEO Canonical From All Pages | |
* Credit: Yoast Team | |
* Last Tested: Jun 16 2017 using Yoast SEO 4.9 on WordPress 4.8 | |
*/ | |
add_filter( 'wpseo_canonical', '__return_false' ); |