2017-05-30 1 views
1

私は多くを検索しましたが、私はこれを特定しませんでした。少なくとも、誰かが感謝することができれば、私の開発スキルはあまり良くありません。Woocommerce固有のバナー商品カテゴリと子ども

私の目標は、例えば、カテゴリXまたはその同じX.

のサブカテゴリー内にある各製品上のテキストを表示することです: フルーツ -Bananas

怒鳴る製品である場合バナナの中にはフルーツに属しているのでコードも表示されます。

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; 
} 

私は毎回クライアントが、私はそれを修正する必要があり、サブカテゴリを追加するので、私のコードは良くありません知っている...

答えて

0

は、私がこれをやって管理:

add_filter('woocommerce_short_description', 'single_product_short_description', 10, 1); 
function single_product_short_description($post_excerpt){ 
global $post; 
$terms = wp_get_post_terms($post->ID, 'product_cat'); 
foreach ($terms as $term) $categories[] = $term->slug; 

if (in_array('piercings', $categories) || in_array('piercings-en', $categories)) { 
    $post_excerpt = $post_excerpt. '<br><div class="product-message"><p>' . __("Bla bla bla", "woocommerce") . '</p></div>'; 
} 

return $post_excerpt; 
} 

・ホープ、この助けてくれる人

関連する問題