get_taxonomy()
get_taxonomy( string $taxonomy )
检索$taxonomy的分类对象。
Retrieves the taxonomy object of $taxonomy.
说明(Description)
get_taxonomy函数将首先检查给定的参数字符串是否是分类对象,如果是,它将返回它。
参数(Parameters)
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
$taxonomy | (string) | 必需 | 要返回的分类对象的名称。 |
返回(Return)
(WP|Taxonomy|false)分类对象,如果$Taxonomy不存在,则为false。
源码(Source)
/** * Retrieves the taxonomy object of $taxonomy. * * The get_taxonomy function will first check that the parameter string given * is a taxonomy object and if it is, it will return it. * * @since 2.3.0 * * @global array $wp_taxonomies The registered taxonomies. * * @param string $taxonomy Name of taxonomy object to return. * @return object|false The Taxonomy Object or false if $taxonomy doesn't exist. */ function get_taxonomy( $taxonomy ) { global $wp_taxonomies; if ( ! taxonomy_exists( $taxonomy ) ) return false; return $wp_taxonomies[$taxonomy]; }
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
2.3.0 | wp-includes/taxonomy.php:261 | 77 | 1 function |
笔记(Notes)
例如,与名为“rentals”的自定义post类型关联的名为“features”的自定义分类法。
get_taxonomy() 为WP2原创文章,链接:https://www.wp2.cn/functions/get_taxonomy/