国产三级农村妇女在线,国产精品毛片a∨一区二区三区,国产乱子伦视频大全,国产精品色拉拉,国产欧美日韩一区二区三区,

首頁 > 技術(shù) > cms教程

WordPress開發(fā)函數(shù)add_post_type_support()

cms教程 2022-10-26 09:23:38

WordPress開發(fā)函數(shù)add_post_type_support(),注冊對某個post類型的某些特性的支持。

用法:

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

描述

所有的核心功能都與編輯屏幕的功能區(qū)域直接相關(guān),比如編輯器或元框。功能包括:“標(biāo)題”,“編輯器”,“評論”,“修訂”,“trackbacks”,“作者”,“摘錄”,“頁面屬性”,“縮略圖”,“自定義字段”和“post-formats”。

此外,' revisions '特性規(guī)定了post類型是否會存儲修訂,而' comments '特性則規(guī)定了評論計數(shù)是否會顯示在編輯屏幕上。

第三個可選參數(shù)也可以隨特性一起傳遞,以提供有關(guān)支持該特性的附加信息。

使用示例:

add_post_type_support( 'my_post_type', 'comments' );

add_post_type_support( 'my_post_type', array(

'author', 'excerpt',

) );

add_post_type_support( 'my_post_type', 'my_feature', array(

'field' => 'value',

) );

參數(shù):

$post_type

(string) (必需) 要為其添加特性的帖子類型。

$feature

(string|array) (必需) 添加的特性接受特性字符串?dāng)?shù)組或單個字符串。

$args

(mixed) (可選) 與某些特性一起傳遞的額外參數(shù)。

更多信息

這個函數(shù)應(yīng)該使用init action鉤子來調(diào)用,就像上面的例子一樣。

多點

要在多站點安裝中顯示“特色圖片”元框,請確保您更新了允許上傳的文件類型,在網(wǎng)絡(luò)管理,網(wǎng)絡(luò)管理設(shè)置子面板#Upload_Settings,媒體上傳按鈕選項。默認是關(guān)閉的。

來源:

文件: wp-includes/post.php

function add_post_type_support( $post_type, $feature, ...$args ) {

global $_wp_post_type_features;

$features = (array) $feature;

foreach ( $features as $feature ) {

if ( $args ) {

$_wp_post_type_features[ $post_type ][ $feature ] = $args;

} else {

$_wp_post_type_features[ $post_type ][ $feature ] = true;

}

}

}

更新日志:
WordPress開發(fā)函數(shù)add_post_type_support() (https://www.wpzt.net/) WordPress開發(fā)教程 第1張
用戶貢獻的筆記

(由Hay貢獻- 11個月前)

關(guān)于所有可能特性的概述(例如' title ', ' editor '等),請參閱post_type_supports文檔。

(由Marc Heatley在4年前貢獻)

不幸的是,

add_post_type_support('page', 'thumbnail');

不會添加特色圖片到頁面。為此,你需要[添加后縮略圖的主題支持

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

add_theme_support()

(由Codex - 6年前貢獻)

這個例子增加了對頁面摘錄的支持(假設(shè)它*不*顯示在“屏幕選項”下):

add_action('init', 'wpdocs_custom_init');

/**

* Add excerpt support to pages

*/

function wpdocs_custom_init() {

add_post_type_support( 'page', 'excerpt' );

}

?>

TAg

加載中~

本網(wǎng)站LOGO受版權(quán)及商標(biāo)保護,版權(quán)登記號:國作登字-2022-F-10126915,未經(jīng)湖南木星科技官方許可,嚴禁使用。
Copyright ? 2012-2022 湖南木星科技有限公司(木星網(wǎng))版權(quán)所有
轉(zhuǎn)載內(nèi)容版權(quán)歸作者及來源網(wǎng)站所有,本站原創(chuàng)內(nèi)容轉(zhuǎn)載請注明來源,商業(yè)媒體及紙媒請先聯(lián)系:aishangyiwan@126.com

工信部備案號:湘ICP備19012813號-5