You should create a small custom function to check the current post (page or other post type) if is parent exist, like the follow function.
/**
* if the post is a subpage for ID.
*
* $post object The post.
*
* return boolean
*/
function is_child( $post ) {
// If is sub_post
if ( is_page() && ( $post->post_parent === $post->ID ) )
return TRUE;
else
return FALSE;
};
I think it is sufficient to check the type and the post_parent
param, but with the ID is it clean and solid. For your requirements should you switch the is_page()
conditional function to ( 'people' === get_post_type() )
.
The helper function is_child
can you now use in your test before you remove the meta boxes, like this.
add_action( 'admin_menu' , 'remove_post_custom_fields' );
function remove_post_custom_fields( $post ) {
if ( is_child( $post ) ){
remove_meta_box( 'staff-typediv' , 'people' , 'normal' );
remove_meta_box( 'practice-areadiv' , 'people' , 'normal' );
}
}