您的当前位置:首页 > 知识博客 > wordpress建站

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

时间:2024-03-13

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

相关函数:

  • get_post_type_object()

  • register_post_type()


欢迎咨询/Welcome to inquire
tel/vx:18842938855
qq:1685522781
email:1685522781@qq.com

Copyright © 2019-2024 asp.cyou


Whatsapp
Powered by RRZCMS