Skip to content

Instantly share code, notes, and snippets.

@DevinWalker
Created May 14, 2014 20:32
Show Gist options
  • Save DevinWalker/ee9d4e53883460c6bbb8 to your computer and use it in GitHub Desktop.
Save DevinWalker/ee9d4e53883460c6bbb8 to your computer and use it in GitHub Desktop.
This code removed the Revolution Slider metabox on pages, posts and CTPs
/**
* Remove Rev Slider Metabox
*/
if ( is_admin() ) {
function remove_revolution_slider_meta_boxes() {
remove_meta_box( 'mymetabox_revslider_0', 'page', 'normal' );
remove_meta_box( 'mymetabox_revslider_0', 'post', 'normal' );
remove_meta_box( 'mymetabox_revslider_0', 'YOUR_CUSTOM_POST_TYPE', 'normal' );
}
add_action( 'do_meta_boxes', 'remove_revolution_slider_meta_boxes' );
}
@Mark-Creeten
Copy link

Mark-Creeten commented Sep 19, 2019

@brianlayman, did you forgot to set the $postType?

like:

 function remove_unwanted_metaboxes( $type, $context, $post ) {
	// This action will be executed for all context: normal, advanced and side
	// If you want to run it only for the normal context, you can.
	// Remove this line and it will check all contexts in case the box has been moved by user
	if ( 'normal' !== $context ) return; 

	// get_current_screen() is defined on most admin pages, but not all.
	// The ones that don't have it won't have metaboxes we care about.
	if ( function_exists( 'get_current_screen' ) ) {
		//get the current post type to use in the in_array()
		$postType = get_post_type();
		// PostTypes hiding this metabox. This could be an object var from $this
		$postTypes = array( 'posttype1', 'posttype2', 'page' ); 
		if ( in_array ( $postType, $postTypes ) ) {
			remove_meta_box( 'wpseo_meta', $postType, $context);
			remove_meta_box( 'postcustom', $postType, $context );
			remove_meta_box( 'rs-addon-typewriter-meta', $postType, $context );
			remove_meta_box( 'mymetabox_revslider_0', $postType, $context ); // Could add _1 _2 etc in case of multiple sliders per page
		}
	}
}

in addition to the solution from @brianlayman, if you have Revolution slider version 6, the metabox ID == 'eg-meta-box'

@brianlayman
Copy link

brianlayman commented Sep 19, 2019

@Mark-Creeten
Ah, yes, my original code had a different condition. So I edited that sample in the gist text editor and didn't test the edit on a site. Thanks for catching that.

@ethanclevenger91
Copy link

Slider Revolution version 6.5.19, the meta box slug is slider_revolution_metabox and its context is side. So wherever you put it, the call needs to be:

remove_meta_box('slider_revolution_metabox', $post_type, 'side');

@brianlayman
Copy link

Slider Revolution version 6.5.19, the meta box slug is slider_revolution_metabox and its context is side.

In my example then, the context check could handled as a switch clause to have the remove_meta_box calls still only execute once for each appropriate context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment