WPDev.one

get_tag()

get_tag( mixed $tag, mixed $output = OBJECT, mixed $filter = 'raw' )

Retrieves a post tag by tag ID or tag object.

Parameters 2 required

Name / Type Description
(int

| WP_Term | object) $tag A tag ID or 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 tag fields. Default 'raw'.

Return Value

((WP_Term)
(WP_Term | array | WP_Error | null) Tag data in type defined by $output parameter. WP_Error if $tag is empty, null if it does not exist.

Function Information

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