wordpress - Wordpress post_submit_box_misc_actions没有数据

  显示原文与译文双语对照的内容
0 0

 function sticker_render_post_button() {
//post form to post_submit_box_misc_actions
 global $post;

 echo '<br><label for="pr_disc">Discount Sticker</label><input name="pr_disc" type="text" value="'.get_post_meta($post->ID,"_whole_discount",true).'" id="pr_disc"/>';

}
//add input
add_action('post_submitbox_misc_actions', 'sticker_post_submitbox_start_action');

$_REQUEST['pr_disc'] 是空的为什么我在尝试插入一个输入,它将更新/添加元数据。

下面是另一部分:


function update_sticker_meta() {
global $post;

$wholedisc=$_REQUEST['pr_disc'];
if (!update_post_meta($post->ID, '_whole_discount', $wholedisc)) {add_post_meta($post-> ID, '_whole_discount',$wholedisc,true);}
return print($wholedisc);

}

add_action('publish_post', 'update_sticker_meta');

时间: 原作者:

0 0

我得用它才能工作


add_action('save_post', 'update_sticker_meta');

原作者:
...