对于遗留数据,我有以下结构
-顶级类别(category)
--子类别(报告)
---发布
我想获得特定顶级类别中的所有帖子。
The problem is all the posts are only assigned to Sub Categories, not their top level categories.
我尝试了以下方法:function getPostsInCategory($category) {
return get_pages(array(
\'post_status\' => \'publish\',
\'post_type\' => \'post\',
\'child_of\' => $category, // e.g \'3\'
\'numberposts\' => -1
));
}
我使用get_pages
而不是get_posts
因为它似乎更能支持继承人制度。我如何才能获得属于我所选类别的子级“报告”中的所有帖子?