我不是经验丰富的编码器,但我们在这里....我使用yoast seo添加开放图形metas。例如,当我在whatsapp上分享一个woocommerce产品时没有通过产品价格...所以即时尝试在标题之后添加价格....当然不起作用: - (
function change_yoast_seo_og_meta() {
add_filter( 'wpseo_opengraph_title', 'change_title' );
}
function change_title( $title ) {
echo $sale_price = get_post_meta( get_the_ID(), '_price', true);
$regular_price = get_post_meta( get_the_ID(), '_regular_price', true);
if ($regular_price == ""){
$available_variations = $product->get_available_variations();
$variation_id=$available_variations[0]['variation_id'];
$variable_product1= new WC_Product_Variation( $variation_id );
$regular_price = $variable_product1 ->regular_price;
}
$title = __( $regular_price, 'change_textdomain' );
return $title;
}