Remove Yoast SEO version from header

September 28th, 2019 Shabu James 1.9K Views 0 Yoast SEO1 minute, 17 seconds

Most wordpress websites has SEO yoast plugin. On installation of SEO Yoast plugin which will add some unwanted codes to header of the website in which it was installed. Which will become a loop hole for hackers to hack the website by viewing the version of the plugin to avoid such situation we will remove it.

For removing the code you need to add the below code to functions.php file in your wordpress active theme or child theme.

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(
'',
''
);
$output = str_ireplace($targets, '', $output);
$output = trim($output);
$output = preg_replace('/^[ \t]*[\r\n]+/m', '', $output);
}
return $output;
}

Hope this tutorial help you. If you have any doubts you can place a comment. Happy blogging.

Tagged under

About The Author

Shabu James

Leave Your Thoughts Here...

We are glad you have chosen to leave a comment. Please keep in mind that comments are moderated according to our comment policy.

Name *
Comment

We are glad you have chosen to leave a comment. Please keep in mind that comments are moderated according to our comment policy.