WordPress获取文章类型对象函数:get_post_type_object

文 / @WordPress主题

WordPress函数get_post_type_object根据文章类型名称获取文章类型数据,返回的结果参考get_post_types()函数$output值为objects时返回的数据。

get_post_type_object( string $post_type )

函数参数

$post_type

字符串

文章类型

函数使用示例

$obj = get_post_type_object( 'post' );
echo $obj->labels->singular_name;

扩展阅读

get_post_type_object()函数位于:wp-includes/post.php

相关函数:

  • get_post_types()
添加UTHEME为好友
扫码添加UTHEME微信为好友
· 分享WordPress相关技术文章,主题上新与优惠动态早知道。
· 微信端最大WordPress社群,限时免费入群。