Skip to content

Instantly share code, notes, and snippets.

@paulcollett
Last active December 19, 2023 04:42
Show Gist options
  • Save paulcollett/4c81c4f6eb85334ba076 to your computer and use it in GitHub Desktop.
Save paulcollett/4c81c4f6eb85334ba076 to your computer and use it in GitHub Desktop.
Remove Yoast HTML Comments “This site is optimized with the Yoast WordPress SEO plugin”
// For Yoast SEO Plugin Version: 14.1+ add to your Wordpress Theme's functions.php...
// Remove All Yoast HTML Comments
// https://gist.github.com/paulcollett/4c81c4f6eb85334ba076
// Credit @devendrabhandari (https://gist.github.com/paulcollett/4c81c4f6eb85334ba076#gistcomment-3303423)
add_filter( 'wpseo_debug_markers', '__return_false' );
// For Yoast SEO Plugin Version: < 14.1 add to your Wordpress Theme's functions.php...
// Remove All Yoast HTML Comments
// https://gist.github.com/paulcollett/4c81c4f6eb85334ba076
// Credit @maxyudin (https://gist.github.com/paulcollett/4c81c4f6eb85334ba076#gistcomment-2937964)
add_action('wp_head',function() { ob_start(function($o) {
return preg_replace('/\n?<.*?yoast seo plugin.*?>/mi','',$o);
}); },~PHP_INT_MAX);
@devendrabhandari
Copy link

devendrabhandari commented May 14, 2020

Now use the below code to remove Yoast HTML Comments from version 14.1
Yoast SEO Plugin Version: 14.1

add_filter( 'wpseo_debug_markers', '__return_false' );

@mohsinr
Copy link

mohsinr commented Jun 19, 2020

Now use the below code to remove Yoast HTML Comments from version 14.1
Yoast SEO Plugin Version: 14.1

add_filter( 'wpseo_debug_markers', '__return_false' );

Thank you! It works!

@f0rtisyy2019
Copy link

Now use the below code to remove Yoast HTML Comments from version 14.1
Yoast SEO Plugin Version: 14.1
add_filter( 'wpseo_debug_markers', '__return_false' );

Thank you! It works!

Also works for me. Thanks

@ulissse
Copy link

ulissse commented Sep 6, 2020

Hello,
It work but is it possible to get rid of all the spaces and tabulations?
Thank you.

@eduardsantamaria
Copy link

Now use the below code to remove Yoast HTML Comments from version 14.1
Yoast SEO Plugin Version: 14.1
add_filter( 'wpseo_debug_markers', '__return_false' );

Thank you! It works!

Also works for me. Thanks

Now use the below code to remove Yoast HTML Comments from version 14.1
Yoast SEO Plugin Version: 14.1

add_filter( 'wpseo_debug_markers', '__return_false' );

It Works! Thank you!

@justinrains
Copy link

Awesome! Thanks for the code. Much appreciated!

@jenkinstm
Copy link

Still works! Thank you.

@ikiyamay
Copy link

Still works! Thank you.

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