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

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

相关函数:

原创文章,作者:,如若转载,请注明出处:https://ce.771633.xyz/1823.html

Like (0)
Previous 2025年3月8日
Next 2025年3月8日

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注