add_post_type_support()

寄存器支持post类型的某些特性。

add_post_type_support(string$post_type,string|array$feature,mixed$args)

说明(Description)

所有核心功能都与编辑屏幕的功能区域直接相关,如编辑器或元框。功能包括:“标题”、“编辑器”、“注释”、“修订”、“trackbacks”、“作者”、“摘录”、“页面属性”、“缩略图”、“自定义字段”和“文章格式”。

此外,“修订”功能指示文章类型是否存储修订,“评论”功能指示评论计数是否显示在编辑屏幕上。

第三个可选参数也可以与功能一起传递,以提供有关支持该功能的附加信息。

示例用法:

添加“文章类型”支持(“我的文章类型”,“评论”);
添加后类型支持(“我的后类型”,数组(
“作者”,“摘录”,
) );

添加后类型支持(“我的后类型”,“我的功能”,数组(

‘字段’=>’值’,

) );

参数(Parameters)

参数类型必填说明
$post_type(string)必需要为其添加功能的文章类型。
$feature(string | array)必需要添加的功能接受功能字符串数组或单个字符串。
$args(mixed)可选与某些特性一起传递的额外参数。

返回(Return)

无返回值


源码(Source)

/**
 * Register support of certain features for a post type.
 *
 * All core features are directly associated with a functional area of the edit
 * screen, such as the editor or a meta box. Features include: 'title', 'editor',
 * 'comments', 'revisions', 'trackbacks', 'author', 'excerpt', 'page-attributes',
 * 'thumbnail', 'custom-fields', and 'post-formats'.
 *
 * Additionally, the 'revisions' feature dictates whether the post type will
 * store revisions, and the 'comments' feature dictates whether the comments
 * count will show on the edit screen.
 *
 * @since 3.0.0
 *
 * @global array $_wp_post_type_features
 *
 * @param string       $post_type The post type for which to add the feature.
 * @param string|array $feature   The feature being added, accepts an array of
 *                                feature strings or a single string.
 */
function add_post_type_support( $post_type, $feature ) {
	global $_wp_post_type_features;
	$features = (array) $feature;
	foreach ($features as $feature) {
		if ( func_num_args() == 2 )
			$_wp_post_type_features[$post_type][$feature] = true;
		else
			$_wp_post_type_features[$post_type][$feature] = array_slice( func_get_args(), 2 );
	}
}
更新版本源码位置使用被使用
5.3.0wp-includes/post.php:185320

笔记(Notes)

有关所有可能的功能(例如“标题”、“编辑器”等)的概述,请参阅post_type_支持的文档。
不幸的是,
本例添加了对页面中摘录的支持(假设它是*而不是*显示在“屏幕选项”下)

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索