Try below code.
$args = array(
'fields' => 'ids',
'post_type' => 'numbers',
'meta_query' => array(
array(
'key' => 'number',
'value' => $number
)
)
);
$my_query = new WP_Query( $args );
if( empty($my_query->have_posts()) ) {
$post_id = wp_insert_post(array (
'post_type' => 'numbers',
'post_title' => $name,
'post_content' => $details,
'post_status' => 'draft',
'tax_input' => $custom_tax,
));
if ($post_id) {
// insert post meta
add_post_meta($post_id, 'number', $number);
}
}
If there is same number in postmeta it will not allow to create post and post meta.
Hope this will helps you.