How to restrict custom field to accept duplicate value

Viewed 714

I am using register_post_type to add an input field, let's say "brand_name". I would like to deny duplicates for that field.

How can I do it in WordPress? Please help me.

Here is my snippet:

function brand_register_meta_boxes() {
if (!class_exists('RW_Meta_Box'))
        return;
    $prefix = 'post_';

    $meta_boxes[] = array(
       'title' => 'Add Brand',
        'pages' => array('brand'),

        'fields' => array(

            array(
            'name' => __( 'Brand Name', 'rwmb' ),
            'desc' => __( 'Add Brand Name', 'rwmb' ),
            'id'   => "{$prefix}title",
            'type' => 'text',
            'required' => true,

            ), 

        )
    );     
        foreach ($meta_boxes as $meta_box) {
        new RW_Meta_Box($meta_box);
    }

}
2 Answers
Related