get_tags()

最后更新于:2021-11-27 00:50:18

get_tags( string|array$args=”)

Retrieves all post tags.

参数

$args

(string|array) (Optional) Arguments to retrieve tags. See get_terms() for additional options.

  • ‘taxonomy’
    (string) Taxonomy to retrieve terms for. Default ‘post_tag’.

Default value: ”

响应

(GC_Term[]|int|GC_Error) Array of ‘post_tag’ term objects, a count thereof, or GC_Error if any of the taxonomies do not exist.

源文件

文件: gc-includes/category.php

function get_tags( $args = '' ) {
	$defaults = array( 'taxonomy' => 'post_tag' );
	$args     = gc_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 GC_Term[]|int|GC_Error $tags Array of 'post_tag' term objects, a count thereof,
		 *                                     or GC_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;
}