上一期通过修改源码的方式解决了Missing field "aggregateRating"和Missing field "review"两项,后来在谷歌后台检测网站时又发现Missing field "hasMerchantReturnPolicy" (in "offers")和Missing field "shippingDetails" (in "offers"),总是修改源码不是好的办法,今天把woocommerce网站翻了个遍,终于找到了可以修改Structured Data的hooks了。
1、修改系统现有的Structured Data
1 | add_filter( 'woocommerce_structured_data_product', function( $schema, $product ) { |
没错,就是这个filter:woocommerce_structured_data_product!