Retrieves category data given a category ID or category object.
Description
If you pass the $category parameter an object, which is assumed to be the category row object retrieved the database. It will cache the category data. If you pass $category an integer of the category ID, then that category will be retrieved from the database, if it isn't already cached, and pass it back. If you look at get_term(), then both types will be passed through several filters and finally sanitized based on the $filter parameter value.
Parameters
$categoryint|object
Category ID or category row object.
$outputstringoptional
The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to a WP_Term object, an associative array, or a numeric array, respectively. Default OBJECT.Default: OBJECT
$filterstringoptional
How to sanitize category fields. Default 'raw'.Default: 'raw'
Return
WP_Term|array|WP_Error|null
Category data in type defined by $output parameter. Returns a WP_Term object with backwards compatible property aliases filled in. WP_Error if $category is empty, null if it does not exist.
Uses · 3
get_term()Gets all term data from database by term ID.
is_wp_error()Checks whether the given variable is a WordPress Error.
_make_cat_compat()Updates category structure to old pre-2.3 from new taxonomy structure.
Used by · 2
get_category_children()Retrieve category children list separated before and after the term IDs.
Signature, return type and hooks compared across 5 parsed releases.
6.8.8
Return type changed from object|array|WP_Error|null to WP_Term|array|WP_Error|null.verified against source
1.5.1
Introduced.from the docblock
About this page
Parsed data
Generated from the wordpress-develop 6.9.7 tag, from src/wp-includes/category.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.