get_post_taxonomies( int|WP_Post $post )
Retrieve all taxonomies of a post with just the names.
描述
参数
- $post
-
(int|WP_Post)
(Optional)
Post ID or WP_Post object. Default is global $post.
返回值
(array) An array of all taxonomy names for the given post.
源代码
File: wp-includes/taxonomy.php
function get_post_taxonomies( $post = 0 ) {
$post = get_post( $post );
return get_object_taxonomies($post);
}
更新日志
Version | 描述 |
---|---|
2.5.0 | Introduced. |
相关函数
Uses
-
wp-includes/taxonomy.php:
get_object_taxonomies() -
wp-includes/post.php:
get_post()
-
Skip to note content
You must log in to vote on the helpfulness of this noteVote results for this note: -1You must log in to vote on the helpfulness of this note
Contributed by
Codex
Displays all taxonomies of a post.
$taxonomy_names = get_post_taxonomies(); print_r( $taxonomy_names );
Output:
Array ( [0] => category [1] => post_tag [2] => post_format )
#return section should say that the function returns an array of all taxonomy names for the given post or post object instead of just an array.
This highlights the main point of difference between get_post_taxonomies and get_object_taxonomies which can return an array of all taxonomy names or an array of all taxonomy objects.
https://codex.wordpress.org/Function_Reference/get_post_taxonomies
你可能对这些文章感兴趣:
- wordpress函数has_filter()用法示例
- wordpress函数has_meta()用法示例
- wordpress函数has_excerpt()用法示例
- wordpress函数has_header_video()用法示例
- wordpress函数has_category()用法示例
- wordpress函数has_custom_logo()用法示例
- wordpress函数has_custom_header()用法示例
- wordpress函数hash_hmac()用法示例
- wordpress函数grant_super_admin()用法示例
- wordpress函数get_the_post_thumbnail_url()用法示例
- wordpress函数hash_equals()用法示例
- wordpress函数got_url_rewrite()用法示例
- wordpress函数gzip_compression()用法示例
- wordpress函数got_mod_rewrite()用法示例
如有疑问,请前往问答中心反馈!
反馈