admin管理员组

文章数量:1306161

I am a wordpress developer. There is a problem I want add multiple headers through metabox in my theme but there is not working. Code:

add_action("admin_init" , "multi_header_meta_box");

function multi_header_meta_box(){
    add_meta_box("multi-header-id" , "Choose Header" , "multi_header_call_function" , "page" , "normal" , "high");
}

function multi_header_call_function(){

    // for slider subtitle
    global $post;
    $subtitledata = get_post_custom($post->ID);
    $subtitlevalue = isset($subtitledata['slider_subtitle']) ? esc_attr($subtitledata['slider_subtitle'][0]) : 'Slider Subtitle';

    echo ' <label for="slider_subtitle">Description for this field</label>
     <select name="slider_subtitle" id="slider_subtitle"  value="'.$subtitlevalue.'" class="postbox">
         <option value="">Select Header</option>
         <option value="">Haeder style 1</option>
         <option value="">Header style 2</option>
     </select>';

}

add_action("save_post", "save_multi_header_style");

function save_multi_header_style(){
    global $post;
    if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
        return $post->ID;
    }

    // for slider subtitle
    update_post_meta($post->ID, "slider_subtitle", $_POST["slider_subtitle"]);

}

本文标签: customizationMultiple header style under meta box