get_tags

The timeline below displays how wordpress function get_tags has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.4

/* Tags */
/**
 * Retrieves all post tags.
 *
 * @since 2.3.0
 *
 * @param string|array $args {
 *     Optional. Arguments to retrieve tags. See get_terms() for additional options.
 *
 *     @type string $taxonomy Taxonomy to retrieve terms for. Default 'post_tag'.
 * }
 * @return WP_Term[]|int|WP_Error Array of '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 {@see get_terms()}.
         */
        $tags = apply_filters('get_tags', $tags, $args);
    }
    return $tags;
}

WordPress Version: 5.5

/* Tags */
/**
 * Retrieves all post tags.
 *
 * @since 2.3.0
 *
 * @param string|array $args {
 *     Optional. Arguments to retrieve tags. See get_terms() for additional options.
 *
 *     @type string $taxonomy Taxonomy to retrieve terms for. Default 'post_tag'.
 * }
 * @return WP_Term[]|int|WP_Error Array of '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;
}

WordPress Version: 5.3

/* Tags */
/**
 * Retrieves all post tags.
 *
 * @since 2.3.0
 * @see get_terms() For list of arguments to pass.
 *
 * @param string|array $args Tag arguments to use when retrieving tags.
 * @return WP_Term[]|int $tags Array of 'post_tag' term objects, or a count thereof.
 */
function get_tags($args = '')
{
    $defaults = array('taxonomy' => 'post_tag');
    $args = wp_parse_args($args, $defaults);
    $tags = get_terms($args);
    if (empty($tags)) {
        $return = array();
        return $return;
    }
    /**
     * Filters the array of term objects returned for the 'post_tag' taxonomy.
     *
     * @since 2.3.0
     *
     * @param WP_Term[]|int $tags Array of 'post_tag' term objects, or a count thereof.
     * @param array         $args An array of arguments. @see get_terms()
     */
    $tags = apply_filters('get_tags', $tags, $args);
    return $tags;
}

WordPress Version: 5.1

/* Tags */
/**
 * Retrieves all post tags.
 *
 * @since 2.3.0
 * @see get_terms() For list of arguments to pass.
 *
 * @param string|array $args Tag arguments to use when retrieving tags.
 * @return WP_Term[]|int $tags Array of 'post_tag' term objects, or a count thereof.
 */
function get_tags($args = '')
{
    $tags = get_terms('post_tag', $args);
    if (empty($tags)) {
        $return = array();
        return $return;
    }
    /**
     * Filters the array of term objects returned for the 'post_tag' taxonomy.
     *
     * @since 2.3.0
     *
     * @param WP_Term[]|int $tags Array of 'post_tag' term objects, or a count thereof.
     * @param array         $args An array of arguments. @see get_terms()
     */
    $tags = apply_filters('get_tags', $tags, $args);
    return $tags;
}

WordPress Version: 4.6

/* Tags */
/**
 * Retrieves all post tags.
 *
 * @since 2.3.0
 * @see get_terms() For list of arguments to pass.
 *
 * @param string|array $args Tag arguments to use when retrieving tags.
 * @return array List of tags.
 */
function get_tags($args = '')
{
    $tags = get_terms('post_tag', $args);
    if (empty($tags)) {
        $return = array();
        return $return;
    }
    /**
     * Filters the array of term objects returned for the 'post_tag' taxonomy.
     *
     * @since 2.3.0
     *
     * @param array $tags Array of 'post_tag' term objects.
     * @param array $args An array of arguments. @see get_terms()
     */
    $tags = apply_filters('get_tags', $tags, $args);
    return $tags;
}

WordPress Version: 4.1

/* Tags */
/**
 * Retrieves all post tags.
 *
 * @since 2.3.0
 * @see get_terms() For list of arguments to pass.
 *
 * @param string|array $args Tag arguments to use when retrieving tags.
 * @return array List of tags.
 */
function get_tags($args = '')
{
    $tags = get_terms('post_tag', $args);
    if (empty($tags)) {
        $return = array();
        return $return;
    }
    /**
     * Filter the array of term objects returned for the 'post_tag' taxonomy.
     *
     * @since 2.3.0
     *
     * @param array $tags Array of 'post_tag' term objects.
     * @param array $args An array of arguments. @see get_terms()
     */
    $tags = apply_filters('get_tags', $tags, $args);
    return $tags;
}

WordPress Version: 3.7

/* Tags */
/**
 * Retrieves all post tags.
 *
 * @since 2.3.0
 * @see get_terms() For list of arguments to pass.
 * @uses apply_filters() Calls 'get_tags' hook on array of tags and with $args.
 *
 * @param string|array $args Tag arguments to use when retrieving tags.
 * @return array List of tags.
 */
function get_tags($args = '')
{
    $tags = get_terms('post_tag', $args);
    if (empty($tags)) {
        $return = array();
        return $return;
    }
    /**
     * Filter the array of term objects returned for the 'post_tag' taxonomy.
     *
     * @since 2.3.0
     *
     * @param array $tags Array of 'post_tag' term objects.
     * @param array $args An array of arguments. @see get_terms()
     */
    $tags = apply_filters('get_tags', $tags, $args);
    return $tags;
}