Missing field “description” in Merchant Listing In wordpress

  • June 15, 2024
  • 0
Hire Vivek Asodariya

If the Google search console is generating the below error then you can add the below code.
Missing field “description”

If you used the Yoast SEO plugin and you generating this error then you can add below code in functions.php file.

Add below code in your (child) theme’s functions.php

add_filter( 'wpseo_schema_product', 'add_product_description_to_schema', 10, 2 );

function add_product_description_to_schema( $data ) {
    global $product;
	$product_description = $product->get_description();
	// Check if the product has variants
    if ( isset( $data['hasVariant'] ) && is_array( $data['hasVariant'] ) ) {
        foreach ( $data['hasVariant'] as &$variant ) {
            

            // Add description to the variant schema data
            if ( ! empty( $product_description ) ) {
                $variant['description'] = wp_strip_all_tags($product_description);
            }
        }
    }
	
    return $data;
}

If you facing any other error then you can contact me.

Leave a Reply

Your email address will not be published. Required fields are marked *