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
版权声明:本文标题:customization - Multiple header style under meta box 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741816766a2399122.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论