post_type_supports()判断某个文章类型(post type)是否可以使用

目录

描述

Checks a post type's support for a given feature.

post_type_supports() 描述

用法

 <?php post_type_supports$post_type$supports ); ?> 

post_type_supports() 用法

参数

$post_type

(string) (必填) Post type. (max. 20 characters)

默认值: None

$supports

(string) (必填) Feature(s) to make available

默认值: None

  • 'title'
  • 'editor' (content)
  • 'author'
  • 'thumbnail' (featured image) (current theme must also support Post Thumbnails)
  • 'excerpt'
  • 'trackbacks'
  • 'custom-fields' (see Custom_Fields, aka meta-data)
  • 'comments' (also will see comment count balloon on edit screen)
  • 'revisions' (will store revisions)
  • 'page-attributes' (template and menu order) (hierarchical must be true)
  • 'post-formats' (see Post_Formats)

post_type_supports() 参数

返回值

(boolean) 

True on success, false on failure.

post_type_supports() 返回值

历史

  • 添加于 版本 3.0

post_type_supports() 历史

源文件

post_type_supports() 函数的代码位于 wp-includes/post.php.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * 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] ) );
}

post_type_supports() 源文件

相关