所以,在寻找几个小时来寻找最简单的保存我的元框的解决方案之后,并没有找到任何可以帮助我的东西......我正在尝试保存这些元框(我将第一个放在下面的示例中,其他的都很漂亮很多重复),而我使用的保存方法根本什么都不做。你能告诉我我在这里做错了什么吗?保存方法是我同事做的另一个插件,但我似乎无法让它工作......
add_action('admin_init','page_spec_meta');
function page_spec_meta()
{
$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ; $template_file = get_post_meta($post_id,'_wp_page_template',TRUE);
if ($template_file == 'index.php')
{
add_meta_box("career-meta", "Career", "career_meta", "page", "normal", "high");
add_meta_box("business-meta", "Business", "business_meta", "page", "normal", "high");
add_meta_box("fabulous-meta", "Fabulous", "fabulous_meta", "page", "normal", "high");
add_meta_box("network-meta", "Network", "network_meta", "page", "normal", "high");
add_meta_box("future-meta", "Future", "future_meta", "page", "normal", "high");
}
}
// --- METABOX: CAREER ... CONTENTS --- //
function career_meta(){
global $post;
$career = get_post_meta( $post->ID, 'career', true );
?>
<label for="career subtitle">Subtitle</label><input type="text" class="widefat" id="career-subtitle" name="career subtitle" value="<?php echo $career; ?>" />
<label for="career text 1">Left Column</label><textarea class="widefat" id="career-text-1" name="career text 1" value="<?php echo $career; ?>"></textarea>
<label for="career text 2">Right Column</label><textarea class="widefat" id="career-text-2" name="career text 2" value="<?php echo $career; ?>"></textarea>
<?php }
// --- METABOX: CAREER ... SAVE --- //
add_action('save_post', 'save_career');
function save_career(){
global $post;
update_post_meta($post->ID, "career", $_POST["career"]);
}
add_action('save_post','function_save_var');
function function_save_var()
{
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
return $post_id;
}
什么有效:元框显示在我指定的页面上,并且是可编辑的什么无效:保存...