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 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线