Last active
July 10, 2023 23:30
-
-
Save mbijon/7311081 to your computer and use it in GitHub Desktop.
Remove 'Add Media' button from above WP editor, per post-type
I remove the media buttons by setting the
media_buttons
setting tofalse
in thewp_editor_settings
filter:/** * Removes media buttons from post types. */ add_filter( 'wp_editor_settings', function( $settings ) { $current_screen = get_current_screen(); // Post types for which the media buttons should be removed. $post_types = array( 'post' ); // Bail out if media buttons should not be removed for the current post type. if ( ! $current_screen || ! in_array( $current_screen->post_type, $post_types, true ) ) { return $settings; } $settings['media_buttons'] = false; return $settings; } );
@deadhead1971 You could add your own post types to the
$post_types
array if you want to have a check for more than one post type.
This worked for me. Thank you!
Here is another way
$settings = array('textarea_name'=>'Overview[Notes]') ;
$settings['media_buttons'] = false;
wp_editor( htmlspecialchars_decode($text), 'mettaabox_ID2', $settings );
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@gchtr thanks!