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

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.

参数

$post_type

(string)

(Required)

The post type for which to add the feature.

$feature

(string|array)

(Required)

The feature being added, accepts an array of feature strings or a single string.

源代码

File: wp-includes/post.php

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 );

}

}

更新日志

Version

描述

3.0.0

Introduced.

相关函数

Used By

wp-includes/class-wp-post-type.php:

WP_Post_Type::add_supports()

wp-includes/post.php:

create_initial_post_types()

User Contributed Notes

Skip to note content

You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note

Contributed by Codex

This example adds support for excerpts in pages (assuming it is *not* showing under “Screen Options”):

add_action('init', 'wpdocs_custom_init');

/**

* Add excerpt support to pages

*/

function wpdocs_custom_init() {

add_post_type_support( 'page', 'excerpt' );

}

?>

Unfortunately,

add_post_type_support('page', 'thumbnail');

won’t add featured images to pages. For that you need to [add theme support for post-thumbnails

add_theme_support( 'post-thumbnails', array( 'post', 'page' ) );

add php support,wordpress函数add_post_type_support()用法示例相关推荐

  1. php中mimes函数,wordpress函数check_upload_mimes()用法示例

    check_upload_mimes( array $mimes ) Check an array of MIME types against a whitelist. 描述 WordPress sh ...

  2. php geteditor,wordpress函数get_editor_stylesheets()用法示例

    get_editor_stylesheets() Retrieve any registered editor stylesheets 描述 返回值 (array) If registered, a ...

  3. php getfooter,wordpress函数get_footer()用法示例

    get_footer( string $name = null ) Load footer template. 描述 Includes the footer template for a theme ...

  4. PHP Calendar 函数,wordpress函数get_calendar()用法示例

    get_calendar( bool $initial = true, bool $echo = true ) Display calendar with days that have posts a ...

  5. escilpe mysql,wordpress函数esc_sql()用法示例

    esc_sql( string|array $data ) Escapes data for use in a MySQL query. 描述 Usually you should prepare q ...

  6. php函数clean(),wordpress函数clean_url()用法示例

    Warning: This function has been deprecated. Use esc_url() instead. clean_url( string $url, array $pr ...

  7. ?php get_sidebar(); ?,wordpress函数get_sidebar()用法示例

    get_sidebar( string $name = null ) Load sidebar template. 描述 Includes the sidebar template for a the ...

  8. html class函数,wordpress函数sanitize_html_class()用法示例

    sanitize_html_class( string $class, string $fallback = '' ) Sanitizes an HTML classname to ensure it ...

  9. php theexcerpt,wordpress的excerpt()函数的用法示例

    本篇文章给大家带来的内容是关于wordpress的excerpt()函数的用法示例,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助. 问题:在wordpres中的single页面,本身引 ...

最新文章

  1. 2021年UI设计培训机构哪个好
  2. 关于双机热备,你该知道那些问题?
  3. 浏览器显示XML文档
  4. 光流 | OpenCV3实现LK Optical Flow(代码类)
  5. let finger cross
  6. VC C/C++ 4种方法获取文件大小 Windows API
  7. Android监听事件
  8. 在 .NET Core 中使用 ViewConfig 调试配置
  9. C#DateTime.ToString格式化时间字符串
  10. Keras-Sequential模型(1)
  11. stupid soso spider
  12. Java 进阶基础知识
  13. snap7 python连接_python snap7 windows-找不到snap7库
  14. arp计算机病毒解决办法,“ARP病毒的解决方案”的解决方案
  15. WinDriver简介(或介绍)
  16. [日志]中国十大名花
  17. 冷色系清新调、日系清新调 、电影色调复古风、欧美风复古,用曲线就可以调了!!!...
  18. 小学生计算机教室注意事项,小学生安全注意事项
  19. 智能硬件产品经理需要具备的知识
  20. 高新技术企业申请流程如何

热门文章

  1. java怎么递归_Java的递归、如何与流相结合
  2. java listutils_Java的list自定义工具类ListUtils
  3. Django第一天笔记
  4. linux中的ip地址、子网掩码、端口
  5. mac找不到mysql_mac找不到mysql
  6. NLP Subword三大算法原理:BPE、WordPiece、ULM
  7. 美团集群调度系统HULK技术演进
  8. 论文浅尝 | 通过多原型实体指称向量关联文本和实体
  9. 推荐:26种NLP练手项目(代码+数据)
  10. 十大双跨平台整体发展情况盘点