Search code examples
wordpresscustom-wordpress-pages

WordPress - update_post_meta not working for a field


I am trying to save some simple meta data on a per post basis, but have discovered that the update_post_meta is not seeming to actually save meta data of one field. The input field is that:

<input size="30" type="text" class="rwmb-text" id="themeum_movie_info_type" name="themeum_movie_info[0][themeum_movie_info_type]">

and i am trying this code to save meta data:

update_post_meta( $get_post_id, 'themeum_movie_info[0][themeum_movie_info_type]', 'Country:' );

Solution

  • I have found a solution. We have to create an array and then have to put the array inside the update_post_meta function like this:

    $array = array(
            '0' => array(
                'themeum_movie_info_type' => 'Country'
            )
    );
    update_post_meta( $get_post_id, 'themeum_movie_info', $array );