Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save AngeliMae/2a9b631a67827762035e86d4a4631d78 to your computer and use it in GitHub Desktop.

Select an option

Save AngeliMae/2a9b631a67827762035e86d4a4631d78 to your computer and use it in GitHub Desktop.
RankMath - Allow changing of the canonical URL
/**
* Allow changing of the canonical URL.
*
* @param
string $canonical The canonical URL.
*/
add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
if( function_exists('um_is_core_page') ){
if ( um_is_core_page('user') ) {
return um_user_profile_url( um_get_requested_user() );
}
}
return $canonical;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment