-
-
Save paulcollett/4c81c4f6eb85334ba076 to your computer and use it in GitHub Desktop.
// 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); |
@TomasHurtz, should be valid PHP5+, maybe your code editor is reporting for earlier versions of PHP.
Glad to hear it's still working for the community!
Thanks. Works great with Yoast v8.2.
It works (WP 4.9 + plugin v5.8) if you get rid of the check on 'WPSEO_VERSION' but I am not sure of any performance or reliability implications.
Specifically://if (defined('WPSEO_VERSION')) { add_action('wp_head',function() { ob_start(function($o) { return preg_replace('/^\n?\<\!\-\-.*?[Y]oast.*?\-\-\>\n?$/mi','',$o); }); },~PHP_INT_MAX); //}
Edit: I just looked through the code and the check for WPSEO_VERSION should really work, so I am a bit puzzled myself. Anyway, consider this a drive-by comment as I wasn't specifically here for this, but just stumbled upon it. But, this is truly a wake up call for me to scrutinize these WordPress plugins more thoroughly.
+1
i use yoast 8.3 and wp 4.9
I tried, and it happened. I cited my source in a paper, thank you.
https://mertsabuncu.com/wordpress-sayfa-kodlarindan-yoast-seo-yorumlarini-kaldirin/
thanks for the information
I tried it
https://www.paktogel.com/data-keluaran-singapura-live-result-sgp-prize/
thanks for the information
I tried it
http://datapengeluarantoto.com/nomor-pengeluaran-togel-hongkong-result-hk-live/
since last update of yoast 11 there is a problem with this cause it is printing code on header
Since plugin version 11 the original code breaks the Knowledge Graph & Schema.org contents (opening <script type='application/ld+json'
tag disappears).
So, change preg_replace()
pattern as follows. May be somebody have more elegant solution.
preg_replace('/\n?<.*?yoast seo plugin.*?>/mi','',$o);
Hi all, I found this function which seems lighter than a "heavy" replace:
/**
* Disable Yoast's Mark and its version.
*/
add_action( 'template_redirect', function () {
if ( ! class_exists( 'WPSEO_Frontend' ) ) {
return;
}
$instance = WPSEO_Frontend::get_instance();
// make sure, future version of the plugin does not break our site.
if ( ! method_exists( $instance, 'debug_love') ) {
return ;
}
// ok, let us remove the love letter.
remove_action( 'wpseo_head', array( $instance, 'debug_love' ), 2 );
}, 9999 );
Also please note that as said by @maxyudin , the previous code breaks the script tag, adding the printed code in the body.
Looks good.. thanks dude... I'll try... http://ideunik.com/
The method seems to be called "debug_mark" in the latest version of Yoast,
So the adapted code of @DennysDionigi working for me on the last version is
/**
* Disable Yoast's Mark and its version.
*/
add_action( 'template_redirect', function () {
if ( ! class_exists( '\WPSEO_Frontend' ) ) {
return;
}
$instance = \WPSEO_Frontend::get_instance();
// make sure, future version of the plugin does not break our site.
if ( ! method_exists( $instance, 'debug_mark') ) {
return ;
}
// ok, let us remove the love letter.
remove_action( 'wpseo_head', [ $instance, 'debug_mark' ], 2 );
}, 9999 );
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' );
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!
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
Hello,
It work but is it possible to get rid of all the spaces and tabulations?
Thank you.
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!
Awesome! Thanks for the code. Much appreciated!
Still works! Thank you.
Still works! Thank you.
This snippet works fine but my functions file complains that the code is not valid!