Skip to content

Instantly share code, notes, and snippets.

@trajche
Last active December 22, 2023 10:54
Show Gist options
  • Save trajche/9305892 to your computer and use it in GitHub Desktop.
Save trajche/9305892 to your computer and use it in GitHub Desktop.
Remove Yoast SEO version from header
add_action('get_header', 'start_ob');
add_action('wp_head', 'end_ob', 999);
function start_ob() {
ob_start('remove_yoast');
}
function end_ob() {
ob_end_flush();
}
function remove_yoast($output) {
if (defined('WPSEO_VERSION')) {
$targets = array(
'<!-- This site is optimized with the Yoast WordPress SEO plugin v'.WPSEO_VERSION.' - https://yoast.com/wordpress/plugins/seo/ -->',
'<!-- / Yoast WordPress SEO plugin. -->',
'<!-- This site uses the Google Analytics by Yoast plugin v'.GAWP_VERSION.' - https://yoast.com/wordpress/plugins/google-analytics/ -->',
'<!-- / Google Analytics by Yoast -->'
);
$output = str_ireplace($targets, '', $output);
$output = trim($output);
$output = preg_replace('/^[ \t]*[\r\n]+/m', '', $output);
}
return $output;
}
@AlchemyUnited
Copy link

Or...just use another plugin :)

We’ve Migrated from Yoast SEO - https://roots.io/weve-migrated-from-yoast-seo/

@paiyasaravanan
Copy link

paiyasaravanan commented Jun 22, 2017

Hello,
How to remove this line from inspect element.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment