I’m trying to get a count of the categories that are subcategories of a category with the id
In the documentation for the term query object, which is the primary argument to get_terms, the
count parameter is listed, with the description:
(bool) Whether to return a term count (true) or array of term objects (false). Will take precedence over $fields if true. Default false.
Based off of this, I think the following code should return an integer term count. However, it does not, it returns an array of term objects, the same as if I didn’t include the
count argument. I’ve tried this with the values 1, “true”, “True” and True as well.
get_terms( array( 'parent' => $categoryId, 'taxonomy' => 'category', 'count' => true ) );
After searching more, I found this code, which works:
wp_count_terms( 'category', array( 'parent' => $categoryId ) );
Why does the
count argument have no effect in this situation? Is this behavior consistent?
- A Parent's Guide - ADHD Medication Long Term Effects
- Short and Long Term Effects of Depression - Be Watchful
- Effective Diets to Lose Weight Fast - Effective Diets That Work
- Work From Home - Have Fun and Get Paid For Doing Survey Work Online
- Why Counting Calories to Lose Weight Does Not Work
- Should You Get Term Life Insurance?
- How to Get a Harder, Thicker Penis Working 17 Minutes a Day
- RCI Timeshare Exchange - 3 Easy Tactics to Get the RCI Timeshare Exchange Working For You
- How to Get Rid of Zits - What Works and What Doesn't
- Count Your Calories For Effective Weight Loss