Skip to content

Instantly share code, notes, and snippets.

@bacoords
Created August 19, 2020 16:44
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 bacoords/0800cf5d5d3ef04f3a28254f5b5aca6d to your computer and use it in GitHub Desktop.
Save bacoords/0800cf5d5d3ef04f3a28254f5b5aca6d to your computer and use it in GitHub Desktop.
c3 yoast canonical fix
/**
* Removes any test urls from Yoast links.
*
* @param [type] $link
* @return void
*/
function c3_fix_yoast_canonical_items( $link ) {
return str_replace(
array(
'c3dti.ai',
'live-c3dti.pantheonsite.io' // add any other weird URLs that might show up
),
'c3.ai/dti',
$link
);
}
add_filter( 'wpseo_canonical', 'c3_fix_yoast_canonical_items' );
add_filter( 'wpseo_next_rel_link', 'c3_fix_yoast_canonical_items' );
add_filter( 'wpseo_prev_rel_link', 'c3_fix_yoast_canonical_items' );
add_filter( 'wpseo_opengraph_url', 'c3_fix_yoast_canonical_items' );
add_filter( 'wpseo_opengraph_image', 'c3_fix_yoast_canonical_items' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment