WPDev.one
Core Function
View Source on Trac ↗

get_category()

get_category( mixed $category, mixed $output = OBJECT, mixed $filter = 'raw' )

Retrieves category data given a category ID or category object.

Parameters 2 required

Name / Type Description
(int

| object) $category Category ID or category row object.

Required
string

$output Optional. 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.

Required
$filter
string

Optional. How to sanitize category fields. Default 'raw'.

Return Value

((WP_Term)
(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.

Function Information

Since Version
1.5.1
Source File
wp-includes/category.php
Advertisement