remove_post_type_support()删除一个自定义的页面类型

目录

描述

Remove support of certain features for a given post type (s). All features are directly associated with a functional area of the 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 edit screen.

Typically remove_post_type_support() should be attached to the 'init' action hook.

remove_post_type_support() 描述

用法

<?php remove_post_type_support$post_type$supports ?>

remove_post_type_support() 用法

参数

$post_type

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

默认值: None

$supports

(string) (必填) Feature to remove.

默认值: None

  • '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 and menu order) (hierarchical must be true)
  • 'post-formats' removes post formats, see Post Formats

remove_post_type_support() 参数

示例

Remove support for excerpts

This example removes support for excerpts in posts:

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */

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

Remove support for post formats

This example removes support for post formats in posts:

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */

add_action( 'init', 'my_remove_post_type_support', 10 );
function my_remove_post_type_support() {
    remove_post_type_support( 'post', 'post-formats' );
}

remove_post_type_support() 示例

历史

  • 添加于 版本 3.0

remove_post_type_support() 历史

源文件

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

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

remove_post_type_support() 源文件

相关