Skip to content

Instantly share code, notes, and snippets.

@nholman7
Created February 27, 2018 00:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nholman7/ece1db2e2352d3e1d94d83a9ba30b4e3 to your computer and use it in GitHub Desktop.
Save nholman7/ece1db2e2352d3e1d94d83a9ba30b4e3 to your computer and use it in GitHub Desktop.
Custom Add HTTPS Canonical to HTTP
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' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment