WordPress检查文章类型是否存在:post_type_exists

本站正在使用的主机

本站目前托管于腾讯云香港轻量服务器,价格便宜访问速度也快,使用本站推荐链接购买还可免费获得WordPress运行环境优化服务。

最新活动 »

WordPress函数post_type_exists检查文章类型是否存在,如果已存在则返回true。通常在使用函数register_post_type()注册文章类型前应该先使用post_type_exists()函数进行检查。

post_type_exists( string $post_type )

函数参数

$post_type

字符串

文章类型

函数使用示例

if ( post_type_exists( 'page' ) ) {
	echo '文章类型page已存在';
} else {
	echo '文章类型page不存在';
}

扩展阅读

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

相关函数:

背字根微信二维码

本站文章均为原创,码字非常不容易,转载请注明原文出处,给苦逼的作者保留一点创作动力。