WordPress函数文档add_post_type_support()
注册一个自定义的页面类型 描述 Registers support of certain feature(s)…
注册一个自定义的页面类型
描述
Registers support of certain feature(s) for a given post type. Each feature has a direct impact on the corresponding field displayed in the post edit screen, such as the editor or a meta box. 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 post edit screen.
用法
<?php add_post_type_support( $post_type, $supports ) ?>
参数
$post_type
(string) (必填) Post type. (max. 20 characters)
默认值: None
$supports
(string/array) (必填) Feature to add.
- ‘title’
- ‘editor’ (content)
- ‘author’
- ‘thumbnail’ (featured image) (current theme must also support Post Thumbnails)
- ‘excerpt’
- ‘trackbacks’
- ‘custom-fields’
- ‘comments’ (also will see comment count balloon on edit screen)
- ‘revisions’ (will store revisions)
- ‘page-attributes’ (
template andmenu order) (hierarchical must be true) (the page template selector is only available for the page post type) - ‘post-formats’ add post formats, see Post Formats
默认值: None
注意
- The function should be called using the init 动作 hook, like in the above example.
历史
- 添加于 版本 3.0
源文件
add_post_type_support() 函数的代码位于 wp-includes/post.php
.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
/* ———————————-
* wordpress函数 kim收集
* ———————————- */
/**
* 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 );
}
}
|
相关
Post Types:
register_post_type(),
add_post_type_support(),
remove_post_type_support(),
post_type_supports(),
post_type_exists(),
set_post_type(),
get_post_type(),
get_post_types(),
get_post_type_object(),
get_post_type_capabilities(),
get_post_type_labels(),
is_post_type_hierarchical(),
is_post_type_archive(),
post_type_archive_title()
- 原文:http://codex.wordpress.org/Function_Reference/add_post_type_support
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
评论功能已经关闭!