admin管理员组文章数量:1333442
Internet does not have a solution for this specific condition. First I create a new post as below:
$user_suan = wp_get_current_user();
$args = array(
'author' => $user_suan->ID,
'post_type' => 'CutePostType',
);
$current_user_posts = get_posts( $args );
if(count($current_user_posts) == 0) {
$my_post = array(
'post_title' => 'COOLPOSTNAME',
'post_status' => 'publish',
'post_type' =>'CutePostType',
'post_author' =>$user_suan->ID
);
wp_insert_post( $my_post );
$current_user_posts = get_posts( $args );
$current_user_post = $current_user_posts[0];
update_post_meta( $current_user_post->ID, 'MYLOVELYMETAFIELD', '');
After that my lovely meta field appear on the edit screen of post. I can populate it by hand. Save or use its all ok. Untill now there is no problem.
But when I use the code below it just removes my lovely meta field from the post edit screen. But at the frontend(post template), I am able to ask for the metafields of the post and display them correctly with proper unserializations. Problem is, I want to see my lovely meta field on the "post edit" page as a lovely string or etc. (wp-admin/post.php action=edit)
$MYLOVELYMETAFIELDVALUE= array('hedge'=>array('sonic'=>'dog','sound'=>'woofwoof'));
update_post_meta( $current_user_post->ID, 'MYLOVELYMETAFIELD', $MYLOVELYMETAFIELDVALUE);
How can I make them editable from post edit page.
Internet does not have a solution for this specific condition. First I create a new post as below:
$user_suan = wp_get_current_user();
$args = array(
'author' => $user_suan->ID,
'post_type' => 'CutePostType',
);
$current_user_posts = get_posts( $args );
if(count($current_user_posts) == 0) {
$my_post = array(
'post_title' => 'COOLPOSTNAME',
'post_status' => 'publish',
'post_type' =>'CutePostType',
'post_author' =>$user_suan->ID
);
wp_insert_post( $my_post );
$current_user_posts = get_posts( $args );
$current_user_post = $current_user_posts[0];
update_post_meta( $current_user_post->ID, 'MYLOVELYMETAFIELD', '');
After that my lovely meta field appear on the edit screen of post. I can populate it by hand. Save or use its all ok. Untill now there is no problem.
But when I use the code below it just removes my lovely meta field from the post edit screen. But at the frontend(post template), I am able to ask for the metafields of the post and display them correctly with proper unserializations. Problem is, I want to see my lovely meta field on the "post edit" page as a lovely string or etc. (wp-admin/post.php action=edit)
$MYLOVELYMETAFIELDVALUE= array('hedge'=>array('sonic'=>'dog','sound'=>'woofwoof'));
update_post_meta( $current_user_post->ID, 'MYLOVELYMETAFIELD', $MYLOVELYMETAFIELDVALUE);
How can I make them editable from post edit page.
Share Improve this question edited Jun 19, 2020 at 3:11 KBA asked Jun 17, 2020 at 20:58 KBAKBA 12 bronze badges1 Answer
Reset to default 0Solution is : https://developer.wordpress/plugins/metadata/managing-post-metadata/#hidden-arrays
Arrays are hidden in default. Please code your own post edit screen.
Thank you myself! This helps another one.
本文标签:
版权声明:本文标题:After updating the custom post type, metafields disappear from the post.php edit menu, how do I fix it? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742290442a2447692.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论