duanganleng0577 2015-10-12 09:48
浏览 98
已采纳

woocommerce获得产品类别ID

I have problem, this very simple question but very important fore me. Thanks fore reading! My Problem: I'm create presentation page with different category. Each presentation blog have title, description, thumbnail and litel custom menu widget where sub category. My page Cases&Bag have section Bags information about Bag, title, description and have custom menu widget where link category Women-Bags and Men-Bags. But under this section i need custom buttom with link to just category all Bags. And need put Buttom

      href="====> Problem heare ( link product category by or or slug ) <===" class="btn btn-default btn-lg manage-btn " role="button">SHOW ALL BAGS</a> 

     Imagen  category-> Cases&Bag/Bags/Women-Bags
        category-> Cases&Bag/Bags/Men-Bags

My code now lock like this:

    <?php // Get the ID of a given category
//$category_id = get_cat_ID( '62' );
// Get the URL of this category
$category_link = get_category_link( 62 );
?>
<!-- Print a link to this category -->
<a href="<?php echo esc_url( $category_link ); ?>" class="btn btn-default btn-lg manage-btn " role="button" title="SHOW ALL BAGS">SHOW ALL BAGS</a>

This not work. It norla? or i have some problem in system?

  • 写回答

1条回答 默认 最新

  • duanju7199 2015-10-12 10:16
    关注

    try this

     <?php
        // Get the ID of a given category
        $category_id = get_cat_ID( 'SHOW ALL BAGS' );
    
    
        // Get the URL of this category
        $category_link = get_category_link( $category_id );
    
    ?>
    
    <!-- Print a link to this category -->
    <a href="<?php echo esc_url( $category_link ); ?>" class="btn btn-default btn-lg manage-btn " role="button" title="SHOW ALL BAGS">SHOW ALL BAGS</a>
    

    Hope this helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了