函数原型
get_post_type( int|WP_Post|null $post = null ): string|false
函数描述
Retrieves the post type of the current post or of a given post.
是否弃用
未弃用
函数参数
-
$post
int|WP_Post|null
Optional - Post ID or post object. Default is global $post.
Default:
null
函数返回值
string|false Post type on success, false on failure.
函数位置
File: wp-includes/post.php.
函数源码
function get_post_type( $post = null ) {
$post = get_post( $post );
if ( $post ) {
return $post->post_type;
}
return false;
}
源码链接
变更日志
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |

