WPDev.one

get_term()

get_term( mixed $term, mixed $taxonomy = '', mixed $output = OBJECT, mixed $filter = 'raw' )

Gets all term data from database by term ID.

Parameters 2 required

Name / Type Description
mixed

(int | WP_Term | object) $term If integer, term data will be fetched from the database, or from the cache if available. If stdClass object (as in the results of a database query), will apply filters and return a `WP_Term` object with the `$term` data. If `WP_Term`, will return `$term`.

Required
$taxonomy
string

Optional. Taxonomy name that `$term` is part of.

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 term fields. Default 'raw'.

Return Value

((WP_Term)
(WP_Term | array | WP_Error | null) WP_Term instance (or array) on success, depending on the `$output` value. WP_Error if `$taxonomy` does not exist. Null for miscellaneous failure.

Function Information

Since Version
2.3.0
Source File
wp-includes/taxonomy.php
Advertisement