描述:

删除自定义文章类型支持的功能

用法:

<?php remove_post_type_support( $post_type, $supports ) ?>

参数:

$post_type

(string) (必填) 指定自定义文章类型(你要删除那个自定义文章类型的功能)

默认值: None

$supports

(string) (必填) 可删除的功能

默认值: None

  • 'title' 标题
  • 'editor' 文章内容
  • 'author'作者信息
  • 'thumbnail' 特色图片
  • 'excerpt' 摘要
  • 'trackbacks'
  • 'custom-fields'
  • 'comments'评论
  • 'revisions' 修订版本
  • 'page-attributes'
  • 'post-formats' 文章形式

示例:

add_action( 'init', 'my_custom_init' );
function my_custom_init() {
	remove_post_type_support( 'post', 'excerpt' );
}

源文件:

/**
 * Remove support for a feature from a post type.
 *
 * @since 3.0.0
 *
 * @global array $_wp_post_type_features
 *
 * @param string $post_type The post type for which to remove the feature.
 * @param string $feature   The feature being removed.
 */
function remove_post_type_support( $post_type, $feature ) {
	global $_wp_post_type_features;

	unset( $_wp_post_type_features[ $post_type ][ $feature ] );
}

 

参与评论