You are here

Disable Yoast features on function.php

// Remove multiple Yoast meta tags
add_filter( 'wpseo_canonical', 'remove_multiple_yoast_meta_tags' );
add_filter( 'wpseo_metadesc', 'remove_multiple_yoast_meta_tags' );
function remove_multiple_yoast_meta_tags( $myfilter ) {
    if ( is_page ( 'about' ) ) {   <-- FILTER BY SLUG
        return false;
    }
    return $myfilter;
}

To completely disable Yoast:

add_action( 'template_redirect', 'remove_wpseo' );

/**
* Removes output from Yoast SEO on the frontend for a specific post, page or custom post type.
*/
function remove_wpseo() {
    if ( is_single ( 1 ) ) {
        $front_end = YoastSEO()->classes->get( Yoast\WP\SEO\Integrations\Front_End_Integration::class );

        remove_action( 'wpseo_head', [ $front_end, 'present_head' ], -9999 );
    }
}

code type: