WordPress - update_post_meta不适用于字段



我正在尝试在每个帖子的基础上保存一些简单的元数据,但发现update_post_meta似乎并没有真正保存一个字段的元数据。输入字段为:

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

我正在尝试使用此代码来保存元数据:

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

我找到了解决方案。我们必须创建一个数组,然后必须将数组放在 update_post_meta 函数中,如下所示:

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

最新更新