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

Function Reference/get tag


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.


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


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

Return Values

Return type based on $output value.



  • 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.


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