get_tag()

最后更新于:2021-11-27 00:49:43

get_tag( int|GC_Term|object$tag, string$output=OBJECT, string$filter=’raw’)

Retrieves a post tag by tag ID or tag object.

参数

$tag

(int|GC_Term|object) (Required) A tag ID or object.

$output

(string) (Optional) The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to a GC_Term object, an associative array, or a numeric array, respectively.

Default value: OBJECT

$filter

(string) (Optional) How to sanitize tag fields.

Default value: ‘raw’

响应

(GC_Term|array|GC_Error|null) Tag data in type defined by $output parameter. GC_Error if $tag is empty, null if it does not exist.

源文件

文件: gc-includes/category.php

function get_tag( $tag, $output = OBJECT, $filter = 'raw' ) {
	return get_term( $tag, 'post_tag', $output, $filter );
}