[Resolved] Hide screen options on custom-post-type

Home Forums Support [Resolved] Hide screen options on custom-post-type

Home Forums Support Hide screen options on custom-post-type

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #238559
    Rodrigo

    Hi Tom,

    I have three different post types (post, video, slider) on my WP site with GeneratePress, and I want to hide various screen options for the users.

    I already hide the screen options for posts, with the following filter:

    add_filter('default_hidden_meta_boxes','hide_meta_box',10,2);
    function hide_meta_box($hidden, $screen) {
        //make sure we are dealing with the correct screen
        if ( ('post' == $screen->base) && ('my-custom-post_type' == $screen->id) ){
          //lets hide everything
          $hidden = array('formatdiv','generate_blog_post_class_meta_box','generate_layout_meta_box','generate_footer_widget_meta_box','generate_pagebuilder_meta_box','generate_de_meta_box','trackbacksdiv','postcostum','commentstatusdiv','commentdiv','slugdiv', 'authordiv','mymetabox_revslider_0','sharing_meta','advads-ad-settings');
          $hidden[] ='my_custom_meta_box';//for custom meta box, enter the id used in the add_meta_box() function.
        }
        return $hidden;
      }

    But I don’t know how to do it with the other post types (video & slider).

    Besides, I’m adding the filters to the funcions.php file of the GeneratePress child theme, but I don’t know if that’s the best way todo it. What would you recommend to do?

    Thanks ins advance,

    #238566
    Tom
    Lead Developer
    Lead Developer

    Hi Rodrigo,

    This might be a question best asked over here: http://wordpress.stackexchange.com/

    Here’s something I found: http://wordpress.stackexchange.com/questions/15376/how-to-set-default-screen-options

    Hope this helps ๐Ÿ™‚

    #238774
    Tom
    Lead Developer
    Lead Developer

    Just came across this so I thought I would share it.

    Here’s how to remove meta boxes for custom post types:

    add_action( 'add_meta_boxes', 'tu_remove_meta_boxes', 999 );
    function tu_remove_meta_boxes() {
    	// Disable elements
    	remove_meta_box('generate_de_meta_box', 'your_post_type', 'side');
    	
    	// Footer widgets
    	remove_meta_box('generate_footer_widget_meta_box', 'your_post_type', 'side');
    	
    	// Sidebar layout
    	remove_meta_box('generate_layout_meta_box', 'your_post_type', 'side');
    	
    	// Page builder integration
    	remove_meta_box('generate_page_builder_meta_box', 'your_post_type', 'side');
    	
    	// Page header
    	remove_meta_box('generate_page_header_meta_box', 'your_post_type', 'normal');
    }
    #409448
    Addison

    This may be elsewhere, but I thought I’d add this for the new Page Header Selector meta box added in GP Premium 1.4:

    // Page header select
    remove_meta_box('generate_select_page_header_meta_box', 'your_post_type', 'normal');
    

    Thanks!

    #409613
    Tom
    Lead Developer
    Lead Developer

    Thanks!

    In GP 2.0, all of the meta boxes are merged into one, so it’ll be much easier to hide ๐Ÿ™‚

    #778594
    Rodrigo

    Thanks. Updating to Resolved.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.