post_type_exists

函数
post_type_exists ( $post_type )
参数
  • (string) $post_type Post type name.
    Required:
返回值
  • (bool) Whether post type is registered.
相关
  • get_post_type_object()
定义位置
相关方法
post_existspost_type_supportsterm_existsget_post_typesget_post_type_object
引入
3.0.0
弃用
-

post_type_exists函数是一个WordPress函数,用来检查一个自定义的文章类型是否在WordPress注册。如果文章类型存在,它返回一个布尔值:true;如果不存在,则返回false。

确定一个文章类型是否被注册。

关于这个和类似主题函数的更多信息,请查看《主题开发者手册》中的{@link Conditional Tags}文章。

function post_type_exists( $post_type ) {
	return (bool) get_post_type_object( $post_type );
}

常见问题

FAQs
查看更多 >
闪电侠

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

2026-01-17 15:03:37

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

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

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