問題描述

我不想使用我的自定義帖子類型頂部的所見即所得。我想使用一個自定義字段 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 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。