WordPress检查自定义文章类型编辑区功能是否支持:post_type_supports

文 / @WordPress主题

WordPress函数post_type_supports用于检查自定义文章类型编辑区功能是否支持。

post_type_supports( string $post_type, string $feature )

函数参数

$post_type

字符串

自定义文章类型

$feature

字符串或数组

要检查的功能,例如:title、editor、comments、revisions、trackbacks、author、excerpt、page-attributes、thumbnail、custom-fields、and post-formats

函数使用示例

检查页面的编辑区是否支持评论:

if ( post_type_supports( 'post', 'comments' ) ) {
	...
}

扩展阅读

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

相关函数:

  • add_post_type_support()
  • remove_post_type_support()
添加UTHEME为好友
扫码添加UTHEME微信为好友
· 分享WordPress相关技术文章,主题上新与优惠动态早知道。
· 微信端最大WordPress社群,限时免费入群。