
使用XAMPP本地搭建WordPress网站图文教程
add_post_type_support ( $post_type, $feature, $args )
add_post_type_support。一个为文章类型增加特定功能支持的函数。它允许开发者向自定义文章类型添加新的功能,如添加文章缩略图或自定义字段。
注册对一个文章类型的某些功能的支持。
所有的核心功能都与编辑屏幕的一个功能区直接相关,如编辑器或元框。功能包括。标题”、”编辑器”、”评论”、”修订”、”回溯”、”作者”、”摘录”、”页面属性”、”缩略图”、”自定义字段”和”文章格式”。
此外,”修订”功能决定了文章类型是否会存储修订,而”评论”功能决定了评论数是否会显示在编辑屏幕上。
第三个可选参数也可以和一个功能一起传递,以提供关于支持该功能的额外信息。
使用实例:
add_post_type_support( ‘my_post_type’, ‘comments’ );
add_post_type_support( ‘my_post_type’, array(
‘author’, ‘excerpt’,
) );
add_post_type_support( ‘my_post_type’, ‘my_feature’, array(
‘field’ => ‘value’,
) );
function add_post_type_support( $post_type, $feature, ...$args ) { global $_wp_post_type_features; $features = (array) $feature; foreach ( $features as $feature ) { if ( $args ) { $_wp_post_type_features[ $post_type ][ $feature ] = $args; } else { $_wp_post_type_features[ $post_type ][ $feature ] = true; } } }