WordPress自定义文章类型添加编辑区功能函数:add_post_type_support

文 / @WordPress主题

WordPress函数add_post_type_support用于为自定义文章类型编辑区添加功能。

add_post_type_support( string $post_type, string|array $feature, mixed $args )

函数参数

$post_type

字符串

自定义文章类型

$feature

字符串或数组

需要添加的功能,例如:title、editor、comments、revisions、trackbacks、author、excerpt、page-attributes、thumbnail、custom-fields、and post-formats

$args

附加参数

函数使用示例

为页面添加摘要功能:

<?php
add_action('init', 'wpdocs_custom_init');
function wpdocs_custom_init() {
    add_post_type_support( 'page', 'excerpt' );
}
?>

扩展阅读

add_post_type_support()函数位于:wp-includes/post.php

相关函数:

  • post_type_supports()
  • remove_post_type_support()
添加UTHEME为好友
扫码添加UTHEME微信为好友
· 分享WordPress相关技术文章,主题上新与优惠动态早知道。
· 微信端最大WordPress社群,限时免费入群。