Forked from AngeliMae/RankMath - Allow changing of the canonical URL
Last active
June 3, 2026 17:13
-
-
Save autocircled/98a8722635e423808155186d937692a3 to your computer and use it in GitHub Desktop.
RankMath - Allow changing of the canonical URL
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
| /** | |
| * Allow changing of the canonical URL. | |
| * | |
| * @param | |
| string $canonical The canonical URL. | |
| */ | |
| add_filter( 'rank_math/frontend/canonical', function( $canonical ) { | |
| return str_replace( | |
| 'https://blog.example.com', | |
| 'https://example.com/blog', | |
| $canonical | |
| ); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment