How to remove SEO Yoast filter?

I installed the wordpress SEO Yoast plugin on my blog. I want to avoid using the SEO Yoast generated header for my blog. Is there a way to remove the filter that the Yoast SEO plugin applies to wp_title()? I want to use the page title as the 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 wrote this code to check the name. And the name in te_before_filter_wp_titleand in te_after_filter_wp_titleis different. Therefore, it is modified by the SEO YOAST plugin.

+4
source share
1 answer

With older versions of WPSEO (v1 ~ 2), you can remove the filter that it applies with the following code:

add_action( 'init', function() {
    global $wpseo_front;
    remove_filter( 'wp_title', array( $wpseo_front, 'title' ), 15 );
}, 20 );

WPSEO (~ 3 +) WordPress (4.4+) () :

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 );
} );
+5

Source: https://habr.com/ru/post/1528911/


All Articles