WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/get tag

Description

Retrieve post tag by tag ID or tag object.

If you pass the $tag parameter an object, which is assumed to be the tag row object retrieved the database. It will cache the tag data.

If you pass $tag an integer of the tag ID, then that tag 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.

Usage

<?php &get_tag$tag$output$filter ?>

Parameters

$tag
(integer|object) (required)
Default: None
$output
(string) (optional) Constant OBJECT, ARRAY_A, or ARRAY_N
Default: OBJECT
$filter
(string) (optional) Default is raw or no WordPress defined filter will applied.
Default: 'raw'

Return Values

(object|array) 
Return type based on $output value.

Examples

Notes

  • Uses: get_term() Used to get the tag data from the taxonomy.

Change Log

Since: 2.3.0

Source File

&get_tag() is located in wp-includes/category.php.

Related

See also index of Function Reference and index of Template Tags.