Retrieves all post tags.
$argsstring|arrayoptional
taxonomy string'post_tag'.Default:''
'post_tag' term objects, a count thereof, or WP_Error if any of the taxonomies do not exist.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;
}
Filters the array of term objects returned for the ‘post_tag’ taxonomy.
| Version | Description |
|---|---|
| 2.3.0 | Introduced. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_tags