我有7个类别(父母),每个类别有15个子类别.
当我选择某个类别(父级)时,我想只显示该特定父类别(父级)的子类别(子级).
点击子类别(子)后,它应该只显示其帖子.
我有一个fron_page.PHP和category.PHP.
如何将其分别写入第一个显示子类别,然后将该子类别分别发布到用户想要查看的新文件中.
解决方法:
此代码应该可以帮助您:
<ul>
<?PHP
$cats = get_the_category();
$mycat = $cats->cat_ID;
wp_list_categories('orderby=id&child_of='.$mycat);
?>
</ul>
要么
<?PHP
if (is_category()) {
$cat = get_query_var('cat');
$this_category = get_category($cat);
$this_category = wp_list_categories('hide_empty=0&hierarchical=true&orderby=id&show_count=0&title_li=&use_desc_for_title=1&child_of='.$this_category->cat_ID."&echo=0");
if($this_category !='<li>No categories</li>')
{
echo '<ul>'.$this_category.'</ul>';
}
}
?>
请告诉我.
祝好运!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。