Retrieves all post tags.
Parameters
$args
string|arrayoptional- Arguments to retrieve tags. See get_terms() for additional options.
taxonomy
stringTaxonomy to retrieve terms for. Default'post_tag'
.
More Arguments from get_terms( … $args )
Array or string of arguments. See WP_Term_Query::__construct() for information on accepted arguments.Default:
''
Source
function get_tags( $args = '' ) {
$defaults = array( 'taxonomy' => 'post_tag' );
$args = wp_parse_args( $args, $defaults );
$tags = get_terms( $args );
if ( empty( $tags ) ) {
$tags = array();
} else {
/**
* Filters the array of term objects returned for the 'post_tag' taxonomy.
*
* @since 2.3.0
*
* @param WP_Term[]|int|WP_Error $tags Array of 'post_tag' term objects, a count thereof,
* or WP_Error if any of the taxonomies do not exist.
* @param array $args An array of arguments. See get_terms().
*/
$tags = apply_filters( 'get_tags', $tags, $args );
}
return $tags;
}
Hooks
- apply_filters( ‘get_tags’,
WP_Term[]|int|WP_Error $tags ,array $args ) Filters the array of term objects returned for the ‘post_tag’ taxonomy.
Changelog
Version | Description |
---|---|
2.3.0 | Introduced. |
Displays a list of tags with links to each one and a specific class for each tag:
Arguments from WP_Term_Query are useful in the input array here. An example, ordering the tags by their names:
Display all tags in list format with links.