Skip to content

Instantly share code, notes, and snippets.

@jflaflamme
Created November 28, 2017 09:29
Show Gist options
  • Select an option

  • Save jflaflamme/8327f08c030af45a8ca9af8406947d86 to your computer and use it in GitHub Desktop.

Select an option

Save jflaflamme/8327f08c030af45a8ca9af8406947d86 to your computer and use it in GitHub Desktop.
wordpress use get_canonical_url to help a domain transition when both domains are active (SEO)
/* Use get_canonical_url to help a domain transition when both domains are active (SEO) and avoiding penality
* apply this on old domain and specify new domain
* Jeff Laflamme <jeff@geekho.asia>
*/
add_filter( 'get_canonical_url', 'geekho_get_canonical_url' );
function geekho_get_canonical_url( $canonical_url ) {
return preg_replace('/oldsite\.com/','newsite.com', $canonical_url);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment