在 WordPress 分类归档页面显示子分类名称及链接,将代码添加到分类归档模板文件主循环的上面:
- <?php
- if ( is_category() ) {
- $this_category = get_category( $cat );
- }
- ?>
- <?php
- if ( $this_category->category_parent )
- $this_category = wp_list_categories( 'orderby=id&show_count=0&title_li=&use_desc_for_title=1&child_of='.$this_category->category_parent."&echo=0" );
- else
- $this_category = wp_list_categories( 'orderby=id&depth=1&show_count=0&title_li=&use_desc_for_title=1&child_of='.$this_category->cat_ID."&echo=0" );
- if ( $this_category ) { ?>
- <ul>
- <?php echo $this_category; ?>
- </ul>
- <?php } ?>
- 1、本站大部分内容均收集于网络,若内容侵犯到您的权益,请发送邮件至:service@wuyanshuo.cn,我们将第一时间处理!
- 2、本站资源所需价格并非资源售卖价格,是收集、整理、编辑以及本站运营的适当补贴,并且本站不提供任何免费技术服务。
- 3、所有资源仅限参考和学习,版权归原作者所有,更多请阅读无言说网络服务器协议。