wordpress add_post_meta more than one key value store

WordPress

add_action('save_post',function($pid){

   add_post_meta($pid,'country','India');

});

on saving post it is creating 3 meta keys/value with country – India,,
i want ti to right now one so that later can add multiple entry for this key,,

Related posts

Leave a Reply

1 comment

  1. Create a Array:

    add_action('save_post',function($pid){
    
    
       $country = array('country_1' => 'India', 'country_2' => 'Cuba', 'country_3' => 'Irlanda'); //Or you can get "get_options('country')" dynamic.
    
       //Or this:
       //$country = array('India', 'Cuba', 'Irlanda');
    
       add_post_meta($pid,'country', $country);
    
    });
    

    I hope help you.