duangekui7451 2016-05-20 06:15 采纳率: 0%
浏览 43
已采纳

显示没有链接wordpress的类别列表

I was trying to list category names. wp_list_categories() returns a list of the categories but the problem is that it automatically wraps the names with links. I do not need the links.

It is possible to disable the links by JavaScript? But then I would have to fire some JS event.

I need to retrieve the category list without the automatic anchor tags, any idea?

  • 写回答

3条回答 默认 最新

  • dongmi4035 2016-05-20 06:19
    关注

    You can achieve this using the wordpress function get_categories(), this should work :

    PHP

     <ul>
      <?php
      foreach (get_categories() as $category){
        echo "<li>";
        echo $category->name;
        echo "</li>";
      } ?>
    </ul>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部