描述:
检查自定义文章类型是否支持某个功能
用法:
<?php post_type_supports( $post_type, $supports ); ?>
参数:
$post_type
(string) (必填) 要检查的自定义文章类型
默认值: None
$supports
(string) (必填) 可以检查的特定功能
默认值: None
- 'title'标题
- 'editor' 文章内容
- 'author'作者信息
- 'thumbnail' 特色图片(前提是主题支持特色图片)
- 'excerpt'摘要
- 'trackbacks'
- 'custom-fields'
- 'comments'评论
- 'revisions'修订版本
- 'page-attributes'(模板和菜单顺序)(层次结构必须为true)(页面模板选择器仅适用于页面发布类型)
- 'post-formats' 文章形式(图像,状态,日志等文章形式)
返回值:
(boolean) True 表示此自定义文章类型支持你所查询的功能,false则相反
源文件:
/**
* Check a post type's support for a given feature.
*
* @since 3.0.0
*
* @global array $_wp_post_type_features
*
* @param string $post_type The post type being checked.
* @param string $feature The feature being checked.
* @return bool Whether the post type supports the given feature.
*/
function post_type_supports( $post_type, $feature ) {
global $_wp_post_type_features;
return ( isset( $_wp_post_type_features[$post_type][$feature] ) );
}