Black Friday Sale! Get $20 off GP Premium, $40 off our new Lifetime license, and 45% off license renewals/extensions! Learn more

Remove metaboxes from posts

Home Forums Support Remove metaboxes from posts

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #168458
    poptimistic

    Hey Tom!
    What do I need to add to functions.php to remove all 3 metaboxes from posts?

    #168515
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Give this a try:

    add_action( 'after_setup_theme','generate_remove_metaboxes' );
    function generate_remove_metaboxes()
    {
        remove_action('add_meta_boxes', 'generate_add_layout_meta_box');
        remove_action('add_meta_boxes', 'generate_add_footer_widget_meta_box');
        remove_action( 'add_meta_boxes', 'generate_add_de_meta_box' );
    }

    Let me know 🙂

    #173695
    poptimistic

    Thanks! It works!

    I would also like to ask how to hide:
    – Page Header metabox for all post types except pages
    – Right and left sidebars widgets

    #173761
    Tom
    Lead Developer
    Lead Developer

    This PHP should work for the Page Header:

    add_action( 'after_setup_theme','generate_remove_page_header_metabox' );
    function generate_remove_page_header_metabox()
    {
        remove_action('add_meta_boxes', 'add_generate_page_header_meta_box');
    }
    
    add_action('add_meta_boxes', 'generate_custom_page_header_metabox');
    function generate_custom_page_header_metabox() { 
    	add_meta_box
    	(  
    		'generate_page_header_meta_box', // $id  
    		__('Page Header','generate-page-header'), // $title   
    		'show_generate_page_header_meta_box', // $callback  
    		'page', // $page  
    		'normal', // $context  
    		'high' // $priority  
    	); 
    }

    Not sure what you mean by left and right sidebar widgets?

    • This reply was modified 4 years, 9 months ago by Tom.
    #174446
    poptimistic

    I mean how unregister left and right sidebar widgets from admin area?

    #290373
    Tom
    Lead Developer
    Lead Developer

    Sorry, I must have missed this post!

    Are you still needing help with this?

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