get_post_type

函数
get_post_type ( $post = null )
参数
  • (int|WP_Post|null) $post Optional. Post ID or post object. Default is global $post.
    Required:
    Default: null
返回值
  • (string|false) Post type on success, false on failure.
定义位置
相关方法
get_post_typesset_post_typeget_post_timeget_post_mime_typeget_post_mime_types
引入
2.1.0
弃用
-

get_post_type: 这个函数检索一个给定文章的文章类型。它接受一个文章ID或文章对象作为其参数,并返回文章类型名称。

检索当前文章或某一特定文章的文章类型。

function get_post_type( $post = null ) {
	$post = get_post( $post );
	if ( $post ) {
		return $post->post_type;
	}

	return false;
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2026-01-29 12:09:40

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: