問題描述
我不想使用我的自定義帖子型別頂部的所見即所得。我想使用一個自定義欄位 textarea,我可以放在我的自定義欄位列表的底部。
這可能嗎?
最佳解決方案
add_action('init', 'init_remove_support',100);
function init_remove_support(){
$post_type = 'your post type';
remove_post_type_support( $post_type, 'editor');
}
把它放在你的主題 functions.php
次佳解決方案
您實際上可以停用所見即所得編輯器,只留下 html 原始碼編輯器。選擇以下功能:
add_filter('user_can_richedit', 'disable_wyswyg_for_custom_post_type');
function disable_wyswyg_for_custom_post_type( $default ){
global $post;
if( $post->post_type === 'product') return false;
return $default;
}
add_filter('user_can_richedit', 'disable_wyswyg_for_custom_post_type');
function disable_wyswyg_for_custom_post_type( $default ){
if( get_post_type() === 'product') return false;
return $default;
}
第三種解決方案
或者,您可以透過 $ args 陣列中的’supports’ 引數直接在您的 register_post_type() 呼叫中處理 post-editor 支援。
預設值為:'supports' => array( 'title', 'editor' )。
您可以將其更改為任何您需要的; 例如:'supports' => array( 'title' )。
第四種方案
Re:這個評論:
I am using Custom Types UI in combo with AdvancedCustomFields.
自定義帖子型別 UI 外掛在其 UI 中公開了所有 register_post_type() $args 陣列引數。
在這種情況下,您只需要找到支援部分,並停用/取消選中編輯器:
參考文獻
注:本文內容整合自 Google/Baidu/Bing 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。
