dongqiao1158 2016-05-12 10:44
浏览 67
已采纳

如何在自定义分类模板中获取分类名称?

I would like to show custom taxonomy name from a page to custom taxonomy template.

e.g My all taxonomies are displaying on a page(xyz) and when i click on particular taxonomy name it goes to my custom taxonomy template (taxonomy-mycustom_tax.php ) but in this page i could not get name of taxonomy from URL.

taxonomy name seeing in URL like(http:/site_name/cust_taxonomy/name_of_term/).

i have also tried like this way..

<?php 
$slugs = explode('/', get_query_var('category_name'));
$currentCategory = get_category_by_slug('/'.end($slugs));
?>
  • 写回答

1条回答 默认 最新

  • dpp42324 2016-05-12 11:40
    关注

    In order to get the taxonomy name in the taxonomy-taxonmyname.php file you can use the following code.

    single_cat_title('prefix', bool $display=true );
    

    The function has two arguements.

    See more about this on https://developer.wordpress.org/reference/functions/single_cat_title/

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

报告相同问题?

悬赏问题

  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口