Taking on legacy data I have the following structure
-Top level category (category)
-- Sub category (report)
--- Post
I want to get all posts in a particular top level category.
The problem is all the posts are only assigned to Sub Categories, not their top level categories.
I've tried the following:
function getPostsInCategory($category) {
return get_pages(array(
'post_status' => 'publish',
'post_type' => 'post',
'child_of' => $category, // e.g '3'
'numberposts' => -1
));
}
I use get_pages
instead of get_posts
because it seems to support heirachy better.
How can I get all posts that are in a "report" that is a child of my chosen category?
get_pages
to get posts