在 WordPress 分类归档页面显示子分类名称及链接

WordPress2343阅读模式

将代码添加到分类归档模板文件主循环的上面:

<?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 } ?>

 

本站文章大部分始于原创,用于个人学习记录,可能对您有所帮助,仅供参考!

weinxin
我的微信
版权声明
本站原创文章转载请注明文章出处及链接,谢谢合作!
 
评论  2  访客  2
    • 禹步网
      禹步网 2

      这个实用

      • 微誓言
        微誓言 1

        我也准备用起来

      匿名

      发表评论

      匿名网友
      :?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

      拖动滑块以完成验证