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
    +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
    Commented Dec 27, 2012 at 19:20

3 Answers 3

9

It should be 'media_buttons' => FALSE.

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

… creates this editor:

enter image description here

4

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');
4

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;
});
2
  • 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
    Commented Apr 25, 2018 at 13:58
  • Thanks! Works great
    – Gavin
    Commented Jun 29, 2023 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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