Hide Metabox Form From WP Admin Post Edit Screen

Support MB Custom Post Type Hide Metabox Form From WP Admin Post Edit ScreenResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #45649
    Nicholas CoxNicholas Cox
    Participant

    Hi

    I have setup a metabox form for a post type of 'product' and noticed that it appears under the post edit page e.g. wp-admin/post.php?post=480&action=edit. How do i hide this from the admin post edit page? I ask as I only want the custom post type to be editable from the front end of the site with front end submission (I have this setup already).

    $meta_boxes[] = [
    	'title'   => 'Test',
    	'post_types' => 'product',
    	'storage_type' => 'custom_table',
    	'table'        => $wpdb->prefix . 'dc_products', // custom mysql table name
    	'id'      => 'dc-product-test'
    	'context' => 'normal',
    	'fields'  => [
    		//fields here...
    	],
    ];

    thanks

    Nick

    #45653
    PeterPeter
    Moderator

    Hello Nick,

    You can use the function is_admin() to check if the current screen isn't in the admin area, then load the meta box.

    if ( !is_admin() ) {
        $meta_boxes[] = [
            ...
        ];
    }
    #46295
    Nicholas CoxNicholas Cox
    Participant

    ok thanks!

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