错误:应在Google Search Console中指定“要约”,“评论”或“ aggregateRating”

时间:2019-06-14 10:22:14

标签: wordpress woocommerce google-search-console

我在我的wordpress网站中使用woocommerce。 “产品”报告已于2月下旬添加到搜索控制台,随之而来的是大量警告和标题为“应提供”,“审阅”或“ aggregateRating”的错误。
您可以在Google Search Console的“增强”部分下找到“产品”报告。该错误的原因是什么?

2 个答案:

答案 0 :(得分:0)

产品架构可能是导致这些错误的原因,请尝试将其添加到您的函数中

/**
 * Remove the generated product schema markup from Product Category and Shop pages.
 */
function wc_remove_product_schema() {
    remove_action( 'woocommerce_shop_loop', array( WC()->structured_data, 'generate_product_data' ), 10, 0 );
}
add_action( 'woocommerce_init', 'wc_remove_product_schema' );

更新

正如您所说的,您将使用特定的yoast woocoommerce插件和该插件文档来添加正确的架构

https://developer.yoast.com/schema-documentation/woocommerce-seo/

答案 1 :(得分:0)

如果您使用的是Yoast,建议您总体上禁用Yoast的架构,但是请记住,如果您使用的是Blog部分,则会损害您的博客。

以下代码将禁用Yoast 11+模式。将其放在您的主题或子主题的functions.php中。

add_filter( 'wpseo_json_ld_output', '__return_false' );

以下代码适用于早期的yoast。

function disable_yoast_schema_data($data){
    $data = array();
    return $data;
}
add_filter('wpseo_json_ld_output', 'disable_yoast_schema_data', 10, 1);