Last active
December 22, 2023 10:54
-
-
Save trajche/9305892 to your computer and use it in GitHub Desktop.
Remove Yoast SEO version from header
This file contains 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
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; | |
} |
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
Or...just use another plugin :)
We’ve Migrated from Yoast SEO - https://roots.io/weve-migrated-from-yoast-seo/