Skip to content

Instantly share code, notes, and snippets.

@robwent
Created April 17, 2019 19:16
Show Gist options
  • Save robwent/f36e97fdd648a40775379a86bd97b332 to your computer and use it in GitHub Desktop.
Save robwent/f36e97fdd648a40775379a86bd97b332 to your computer and use it in GitHub Desktop.
Remove Yoast HTML Comments “This site is optimized with the Yoast WordPress SEO plugin” with Yoast v11
//Remove Yoast HTML Comments
//https://gist.github.com/robwent/f36e97fdd648a40775379a86bd97b332
function go_yoast() {
if (defined('WPSEO_VERSION')){
add_action('get_header',function (){ ob_start(function ($o){
return preg_replace('/\n?<.*?Yoast SEO plugin.*?>/mi','',$o); }); });
add_action('wp_head',function (){ ob_end_flush(); }, 999);
}
}
add_action('plugins_loaded', 'go_yoast');
@justinrains
Copy link

justinrains commented Oct 17, 2020

No cache installed. It's still in the source of the page.

@robwent
Copy link
Author

robwent commented Oct 19, 2020

@justinrains Try this instead: https://gist.github.com/paulcollett/4c81c4f6eb85334ba076

It's updated more often.

Looks like they have added a filter now so you only need a single line that shouldn't break in the future:

add_filter( 'wpseo_debug_markers', '__return_false' );

@justinrains
Copy link

justinrains commented Oct 19, 2020 via email

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