1
爲了保持簡短:我構建了一個包含3個字段的元框,但它只保存第一個字段。我可能做錯了什麼?元框僅保存多個輸入字段中的第一個
// --- METABOX: CAREER ... CONTENTS --- //
function career_meta(){
global $post;
$career1 = get_post_meta($post->ID, 'career1', true);
$career2 = get_post_meta($post->ID, 'career2', true);
$career3 = get_post_meta($post->ID, 'career3', true);
?>
<label for="career_subtitle">Subtitle</label><input type="text" class="widefat" id="career-subtitle" name="career_subtitle" value="<?php echo $career1; ?>" />
<label for="career_text_1">Left Column</label><textarea class="widefat" id="career-text-1" name="career_text_1" value="<?php echo $career2; ?>"></textarea>
<label for="career_text_2">Right Column</label><textarea class="widefat" id="career-text-2" name="career_text_2" value="<?php echo $career3; ?>"></textarea>
<?php }
// --- METABOX: CAREER ... SAVE --- //
add_action('save_post', 'save_career');
function save_career(){
global $post;
update_post_meta($post->ID, "career1", $_POST["career_subtitle"]);
update_post_meta($post->ID, "career2", $_POST["career_text_1"]);
update_post_meta($post->ID, "career3", $_POST["career_text_2"]);
}
add_action('save_post','function_save_var');
function function_save_var()
{
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return $post_id;
}
這就是我現在所擁有的。它節省了第一個領域(career_subtitle),但不是其他兩個領域。修復這是非常重要的,所以我真的很感謝有效的答案:)
完全錯過了!謝謝 :) –