最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - Get a list of Product Categories inside a loop

programmeradmin3浏览0评论

I am trying to list out product categories as a list

  • Farm Cycle: 6 Months
  • KADUNA

    The code below output as
    Farm Cycle: 6 Months, KADUNA

    add_action( 'wpo_wcpdf_after_item_meta', 'wpo_wcpdf_show_product_categories', 10, 3 );
    function wpo_wcpdf_show_product_categories ( $template_type, $item, $order ) {
        // get a comma separated list of categories (category links stripped)
        if (isset($item['product'])) {
    
            echo '<div class="product-categories">DETAILS:<br/> '.strip_tags( wc_get_product_category_list( $item['product']->get_id() ) ).'</div>';
        }
    }
    

    I am trying to list out product categories as a list

  • Farm Cycle: 6 Months
  • KADUNA

    The code below output as
    Farm Cycle: 6 Months, KADUNA

    add_action( 'wpo_wcpdf_after_item_meta', 'wpo_wcpdf_show_product_categories', 10, 3 );
    function wpo_wcpdf_show_product_categories ( $template_type, $item, $order ) {
        // get a comma separated list of categories (category links stripped)
        if (isset($item['product'])) {
    
            echo '<div class="product-categories">DETAILS:<br/> '.strip_tags( wc_get_product_category_list( $item['product']->get_id() ) ).'</div>';
        }
    }
    
    Share Improve this question asked Jun 12, 2019 at 12:38 Odutola AbisoyeOdutola Abisoye 31 bronze badge 0
    Add a comment  | 

    1 Answer 1

    Reset to default 0

    Please try this code this will give you categories in list format: echo '<ul>' . wc_get_product_category_list( $item['product']->get_id(), '</li><li>', '<li>', '</li>' ) . '</ul>';

  • 发布评论

    评论列表(0)

    1. 暂无评论