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

WPOCN WordPress教程评论43阅读模式

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

<?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
我的微信
我的微信
微信扫一扫
 
WPOCN
  • 本文由 WPOCN 发表于 2022年5月20日21:11:42
  • 转载请务必保留本文链接:https://www.tghello.com/3997.html

发表评论