'How to disable title and description meta tags in Yoast SEO

I have another title, description tag autogenerate filter plugin for product category.

I want delete meta title tag in Yoast SEO.

Previously it was possible to remove meta title with this code:

add_filter( 'wpseo_title', 'remove_category_wpseo_title' );

function remove_category_wpseo_title( $title ) {
    if ( is_product_category() || is_shop() ) {
        return false;
    }
    
    return $title;
}

But now it's not working.

I found in dev portal, but this code delete all meta data.

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_product_category() || is_shop() ) {
        $front_end = YoastSEO()->classes->get( Yoast\WP\SEO\Integrations\Front_End_Integration::class );

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

I disable Presenters, except 'robots'

function intervik_wpseo_frontend_presenters($presenters){

    $keep[] = 'Yoast\WP\SEO\Presenters\Robots_Presenter';
    
    /* remove ALL, except robots on PAGES */
    if(is_product_category() || is_shop()) return $keep;
        else return $presenters;
}
add_filter('wpseo_frontend_presenter_classes', 'intervik_wpseo_frontend_presenters', 10, 1);

And this code disable my 'add_theme_support( 'title-tag' );'

How do I disable Yoast SEO title and description meta tags from product category?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source