[Resolved] Remove metaboxes for CPT when using Gutenberg

Home Forums Support Remove metaboxes for CPT when using Gutenberg

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #926758
    lsitlabs

    Hi,

    In the past I was able to remove GeneratePress metaboxes from CPT using the various generate_layout_meta_box, generate_footer_widget_meta_box, etc. filters.

    However, it seems that for CPTs where Gutenberg editor is enabled, this no longer works.

    Is there an alternative way of doing this that works with Gutenberg?

    #926855
    David
    Staff
    Customer Support

    Hi there,

    Do you want to disable them for all post types? If so:
    in the Gutenberg editor > Show More Tools & Options ( 3 dot ) menu in the far right of topbar select Options where you can disable any meta boxes you dont want. This setting will be saved as the default for the user.

    #926887
    lsitlabs

    Hi David,

    Thank you for your reply.

    Unfortunately that would not work for my use case.

    I was looking at a solution that would allow to programmatically remove metaboxes for select CPTs via code.

    Currently, as mentioned, is fairly easy to do that when Gutenberg is not active for a CPT, however remove_meta_box does not seem to work for GeneratePress metaboxes on Gutenberg-enabled CPTs.

    It might be worth mentioning that same technique works for other metaboxes added by other plugins (for example: Revolution Slider) so I am not sure this is a general Gutenberg issue.

    #927175
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You should be able to do this:

    add_action( 'add_meta_boxes', function() {
        remove_meta_box( 'generate_layout_options_meta_box', 'page', 'side' );
    }, 999 );

    page is the name of the post type.

    Note that in this code, we’re referencing side as that’s where the metabox is in GP 2.3, which is set to be released next week. You can install the beta now for this code to work: https://generatepress.com/generatepress-2-3/

    #928541
    lsitlabs

    Hi Tom,

    Thanks.

    Turns out that I was using “generate_layout_meta_box” instead of “generate_layout_options_meta_box” in my code.

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