Remove GeneratePress Layout Metabox

tdrayson

I’ve wanted to remove the GeneratePress layout metabox in the sidebar for a while in my starter site, as I control everything using my own layout / template system, and it causes more confusion than it solves.

This handy snippet allows you to disable it everywhere.

Code Snippet

Add the code below to functions.php or code snippet plugin.

PHP

        /**
 * Remove GP Layout Metabox
 * 
 * @source SnippetClub
 * @author Taylor Drayson
 */
function tct_remove_gp_layout_metabox() {
	$post_types = get_post_types( array( 'public' => true ) );
    remove_meta_box( 'generate_layout_options_meta_box' , $post_types , 'side' ); 
}
add_action( 'admin_head' , 'tct_remove_gp_layout_metabox' );
      
Copy

By default, this snippet excludes the metabox on every single public registered post type.

If you wanted to exclude only certain post types, you could modify the $post_types line with:

PHP

        $post_types = array('post', 'page');
      
Copy

This way you pass in the post types you want to remove it from.

👋🏻 Weekly Tutorial Digest

I send out a weekly newsletter with links to new tutorials written in the last week, you can subscribe below.

Newsletter

🔒I won't send you spam, I promise