Created
November 28, 2017 09:29
-
-
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)
This file contains hidden or 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
| /* 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