我正在使用此代码在Wordpress中生成两个类别列表:
<h2>Headline 1</h2>
<article class="post" id="post-<?php the_ID(); ?>">
<ul class="columns">
<?php echo wp_list_categories('title_li=&hide_empty=0&exclude=1,54,55'); ?>
</ul>
</article>
<h2>Headline 2</h2>
<article class="post" id="post-<?php the_ID(); ?>">
<ul class="columns">
<?php echo wp_list_categories('title_li=&hide_empty=0&include=54,55'); ?>
</ul>
</article>
有没有取消链接没有任何帖子的类别?我仍然希望它们在列表中可见,但不是链接。
谢谢!
答案 0 :(得分:0)
<?php if (get_category('17')->category_count > 0) echo "<a
href=\"".get_bloginfo('home')."/category/news/\">Blog</a>"; ?>
您只能获得仅包含帖子的类别的链接,否则您将无法获得类别名称的链接,但类别名称将显示在列表中。