18

I dont want to use the WYSIWYG at the top of my Custom Post Type. I want to use a custom field textarea that i can place at bottom of my list of custom fields instead.

Is this possible?

19
add_action('init', 'init_remove_support',100);
function init_remove_support(){
    $post_type = 'your post type';
    remove_post_type_support( $post_type, 'editor');
}

place it to your themes functions.php

  • 1
    Note: I would recommend calling remove_post_type_support() inside the same callback that you call register_post_type(), to ensure proper order of execution. – Chip Bennett Nov 16 '12 at 16:21
  • I dont see register_post_type() in functions.php. I am using Custom Types UI in combo with AdvancedCustomFields. – scottgemmell Nov 16 '12 at 16:42
  • That you're using the Custom Post Types UI Plugin is a rather important detail to your question. :) The Plugin exposes the supports parameter in its UI. Refer to these screenshots. – Chip Bennett Nov 16 '12 at 16:58
12

You can actually disable the WYSIWYG editor, leaving only the html source editor. Choose a function below:

// disable wyswyg for custom post type, using the global $post
add_filter('user_can_richedit', function( $default ){
  global $post;
  if( $post->post_type === 'product')  return false;
  return $default;
});

// disable wyswyg for custom post type, using get_post_type() function
add_filter('user_can_richedit', function( $default ){
  if( get_post_type() === 'product')  return false;
  return $default;
});
  • is there a way to only remove the WYSIWYG from the excerpt? My theme has it turned on, and I'm dubious about some of their code, I'm not sure I can remove it. I asked this as a new question here: wordpress.stackexchange.com/questions/300877/… – Jason Apr 16 '18 at 6:13
  • Hi, honestly, I don't know, my WP knowledge is a bit rusty, sorry. The only thing I can suggest is to dig into the WP source code, find something relevant, then duckduckgo/google it for documentation/examples. – biziclop Apr 17 '18 at 6:32
9

Alternatively, you can handle post-editor support directly in your register_post_type() call, via the 'supports' parameter in the $args array.

The default value is: 'supports' => array( 'title', 'editor' ).

You can change it to whatever you need; for example: 'supports' => array( 'title' ).

6

Re: this comment:

I am using Custom Types UI in combo with AdvancedCustomFields.

The Custom Post Types UI Plugin exposes all of the register_post_type() $args array parameters in its UI.

In this case, you simply need to find the Supports section, and disable/uncheck Editor:

Custom Post Types UI Plugin - Register Post Type options

  • Even though another answer was set as the selected answer, this is the correct answer. There's no need to run a filter to remove something that you can just exclude when declaring the CPT to begin with. – butlerblog Aug 13 '17 at 18:56
-1

Another, more consistent way to disable the WYSIWYG editor, leaving only the html source editor - is to disallow tinymce using "wp_editor_settings" filter for your custom post type.

function my_post_type_editor_settings( $settings ) {

    global $post_type;

    if ( $post_type == 'my_post_type' ) {

        $settings[ 'tinymce' ] = false;
    }

    return $settings;
}

add_filter( 'wp_editor_settings', 'my_post_type_editor_settings' );
  • Please edit your answer, and add an explanation: why could that solve the problem? – fuxia May 11 '17 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.