-1
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']爲空。爲什麼?我試圖插入一個輸入,它會更新/添加元數據在其後。Wordpress post_submit_box_misc_actions no data
剛剛澄清,這裏是另一部分:
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');
將此標記爲一個答案,如果它解決了這個問題。 – 2012-07-16 13:08:56