Update get_category Function Reference
The function reference page for get_category is incomplete in my eyes, and could use an additional piece of information.
Returns an array of category objects matching the query parameters.
Arguments are pretty much the same as wp_list_categories and can be passed as either array or in query syntax.”
I was using this code:
$descendants = get_categories(array('child_of' => 2));
What’s not listed here, is that if there are no posts in a category, those categories will not be returned. I was redoing my theme, and added a bunch of sub-categories, and had no posts currently in those categories, but planned on using them. When attempting to loop through all sub-categories, I was told I had X children, when I knew there were Y. Using my knowledge of programming, I eventually discovered the issue was due to those categories not having posts in them, but that’s extremely sloppy documentation, and very important information that should be shared with developer’s reading the function reference.
Please add something along these lines:
“No results will be returned for categories that do not contain posts.” – smoother / more informal wording can be done, but you get the picture.
- The topic ‘Update get_category Function Reference’ is closed to new replies.