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

蜡笔 WordPress经验评论157阅读模式

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

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

weinxin
我的微信
微信及版权声明
本站原创文章转载请注明文章出处及链接,谢谢合作!其他文章来源于网络,如有侵权,请联系我!
WordPress经验

禁止 WordPress 发送电子邮件通知

默认情况下,当WordPress有新用户注册或用户更改密码和电子邮件地址,WordPress会发送电子邮件通知你或者用户。 如果不需要邮件通知,可以将下面代码添加到主题函数模板functions.ph...
评论  0  访客  0
匿名

发表评论

匿名网友

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

确定