I have a CTP named leads
and have 2 metaboxes added to the CPT new/edit screen. I need to have one of them only in edit screen, not in add new.
Played with the codes provided in couple of answers, but they weren’t of much help. (97845 and 89395)
Can anyone help? I don’t necessarily want anyone to do it for me, but a few playable starts would be great.
Thanks
1 Answer
Check the action
of the current screen object for add
:
function wpd_add_meta_box() {
$screen = get_current_screen();
if( 'add' != $screen->action ){
add_meta_box(
'myplugin_sectionid',
'My meta box',
'myplugin_meta_box_callback',
'leads'
);
}
}
add_action( 'add_meta_boxes', 'wpd_add_meta_box' );