- This topic has 6 replies, 1 voice, and was last updated 1 year, 10 months ago by
Matt Litzinger.
-
AuthorPosts
-
October 24, 2016 at 9:14 pm #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,
October 24, 2016 at 11:18 pm #238566Tom
Lead DeveloperLead DeveloperHi 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 ๐
October 25, 2016 at 10:56 am #238774Tom
Lead DeveloperLead DeveloperJust 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'); }
October 24, 2017 at 2:44 pm #409448Addison
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!
October 24, 2017 at 10:56 pm #409613Tom
Lead DeveloperLead DeveloperThanks!
In GP 2.0, all of the meta boxes are merged into one, so it’ll be much easier to hide ๐
January 10, 2019 at 11:44 am #778594Rodrigo
Thanks. Updating to Resolved.
March 23, 2023 at 9:57 am #2579106Matt Litzinger
I was able to update the above code to the following in 2023 and get this to work.
remove_meta_box('generate_layout_options_meta_box', 'your_post_type', 'side');
-
AuthorPosts
- You must be logged in to reply to this topic.