我有数据类别:
- About us
-- Sub 1 about us
-- Sub 2 about us
分类中
About us
a已添加帖子:
About us 1, About us 2, About us 3....
在子类别中Sub 1 about us
我已添加列表帖子:Sub 1 about us 1, Sub 1 about us 2...
在子类别中Sub 2 about us
我已添加列表帖子:Sub 2 about us 1, Sub 2 about us 2...
如何:
在存档类别中About us
回音列表帖子Sub 1 about us & Sub 2 about us
不显示About us 1, About us 2, About us 3....
在类别中About us
有什么想法吗?
谢谢
最合适的回答,由SO网友:sankorati 整理而成
也许像这样的事情可以吗?
$cat = \'About us\';
$tax = \'category\';
$cat_id = get_cat_ID($cat);
$category = get_term_children($cat_id, $tax);
$pre = \'\';
foreach ($category as $sub)
{
$cat_list .= $pre . $sub;
$pre = \', \';
}
query_posts(array( \'cat\' => $cat_list, \'posts_per_page\' => 1000));
echo \'<ul>\';
while ( have_posts() ) : the_post();
echo \'<li>\';
the_title();
echo \'</li>\';
endwhile;
echo \'</ul>\';