admin管理员组

文章数量:1122846

I am using Yoast plugin on my WordPress site, mainly for the sitemap and indexing features. My theme already comes with SEO features so now I am getting an error saying there's duplicate meta description. How can I disable the Yoast meta description on all pages?

Disabling on the theme side is not an option. I tried leaving one blank but it auto-generated a meta description and the duplicate issue persisted.

I am using Yoast plugin on my WordPress site, mainly for the sitemap and indexing features. My theme already comes with SEO features so now I am getting an error saying there's duplicate meta description. How can I disable the Yoast meta description on all pages?

Disabling on the theme side is not an option. I tried leaving one blank but it auto-generated a meta description and the duplicate issue persisted.

Share Improve this question edited May 25, 2024 at 15:41 fuxia 107k38 gold badges255 silver badges459 bronze badges asked May 25, 2024 at 8:27 houjichahoujicha 31 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

This should do the job:

<?php

/**
Plugin Name: wpse425362
Description: Site specific code changes for example.com
*/

if (!defined('ABSPATH')) exit; // Exit if accessed directly   

/**
 * Removes the meta description generated by Yoast
 *
 * @param array $presenters the registered presenters.
 *
 * @return array the remaining presenters.
 */
function wpse425362_remove_description( $presenters ) {
    return array_map( function( $presenter ) {
        if ( ! $presenter instanceof Meta_Description_Presenter ) {
            return $presenter;
        }
    }, $presenters );
}

add_action( 'wpseo_frontend_presenters', 'wpse425362_remove_description' );

Save this as /wp-content/plugins/wpse425362/wpse425362.php and activate it in the plugins menu.

本文标签: pluginsHow to disable Yoast meta description for all pages