7

I have a custom post type which supports editor. (WordPress version 3.5)

I want to customize the editor for it.

  1. Make it readonly
  2. Hide "Add Media" button
  3. Hide HTML editor
  4. Remove status bar showing word count

I am using the following code:

add_filter( 'tiny_mce_before_init', function( $args ) {
     $args['readonly'] = 1;
     $args['media_buttons'] = 0;
     $args['theme_advanced_disable'] = "code";
     return $args;
});

Only readonly is working. Is it not possible to do other customization using tiny_mce_before_init?

  • 1
    +1, it's an interesting question. But in Wordpress, the "Add media" button is not directly integrated into TinyMCE, but stays outside of it. I don't think you can disable it via the TinyMCE configuration. I'm just guessing, but disable adding media sounds to me like prohibiting access to the media library. So maybe this could be achieved by setting/removing the appropriate rights to/from the user role. – feeela Dec 27 '12 at 19:20
7

It should be 'media_buttons' => FALSE.

array (
    'textarea_rows' => 5,
    'media_buttons' => FALSE,
    'teeny'         => TRUE,
    'tinymce'       => TRUE
)

… creates this editor:

enter image description here

2

If you want to hide/disable/prevent/remove the "Add Media"-button in 2018 you can do the following (in essence):

// probably in your functions.php
remove_action('media_buttons', 'media_buttons');
1

In WordPress ver 4.9 it does not seem media buttons can be turned off using the 'tiny_mce_before_init' hook.

Instead I was able to remove this using 'wp_editor_settings', like so:

add_filter( 'wp_editor_settings', function($settings) {
  $settings['media_buttons']=FALSE;
  return $settings;
});
  • 3
    Well, as this was the first resource I came across when trying to disable the media button in my theme, and I had to spend some time to work out how to do it, it may make a difference to someone. – Ben Apr 25 '18 at 13:58

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.