I have installed the wordpress SEO Yoast plugin on my blog. I want to avoid using SEO Yoast generated title for my blog. Is there any way I can remove filter that are being applied by SEO Yoast plugin for wp_title()
?
I want to use the page title as SEO title.
add_filter( 'wp_title', 'te_before_filter_wp_title' );
function te_before_filter_wp_title( $title ) {
echo $title;
//exit;
return $title;
}
add_filter( 'wp_title', 'te_after_filter_wp_title' ,9999);
function te_after_filter_wp_title( $title ) {
echo $title;
//exit;
return $title;
}
I have write this code to test the title. And title in te_before_filter_wp_title
and in te_after_filter_wp_title
is different. So it is being modified by SEO YOAST plugin.
With older versions of WPSEO (v1~2), you can remove the filter it applies with the following code:
add_action( 'init', function() {
global $wpseo_front;
remove_filter( 'wp_title', array( $wpseo_front, 'title' ), 15 );
}, 20 );
With newer versions of WPSEO (~3+) and WordPress (4.4+), the filter(s) can be removed with the following code:
add_action( 'init', function () {
$wpseo_front = WPSEO_Frontend::get_instance();
remove_filter( 'pre_get_document_title', array( $wpseo_front, 'title' ), 15 );
remove_filter( 'wp_title', array( $wpseo_front, 'title' ), 15 );
} );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With