【发布时间】:2017-05-30 08:50:46
【问题描述】:
我已经搜索了很多,但我没有找到任何具体的,或者至少,我的开发技能还不是很好,如果有人可以帮助我感激的话。
我的目标是在类别 X 或同一 X 的子类别内的每个产品上显示文本。
例如: 水果 -香蕉
如果波纹管产品在 Bananas 内,它也会显示代码,因为它属于 Fruits。
add_filter( 'woocommerce_short_description', 'single_product_short_description', 10, 1 );
function single_product_short_description( $post_excerpt ){
if ( is_product_category(array(140,20)) )
$post_excerpt = $post_excerpt. '<br><div class="product-message"><p>' . __( "Whats the measure? <a href='/#right-measure' target='_blank'>Check</a>.", "woocommerce" ) . '</p></div>';
return $post_excerpt;
}
我知道我的代码不好,因为每次客户添加子类别时我都必须修复它...
【问题讨论】:
标签: php wordpress woocommerce