admin管理员组文章数量:1390519
How can i make this meta box please help?
function add_custom_meta_box1()
{
add_meta_box(
'meta-box1',
'Featured Image Settings ',
'custom_meta_box_callback1',
'page',
'side',
'low'
);
}
add_action('add_meta_boxes', 'add_custom_meta_box1');
function custom_meta_box_callback1(){
global $post;
wp_nonce_field( basename(__FILE__ ), 'custom_meta1_nonce');
$custom_stored_meta1 = get_post_meta( $post->ID, 'drop_down', true );
?>
<li>
<label>Background Fit:</label>
<br>
<select id="emeta[]" name="emeta[]">
<option>Cover</option>
<option>Contain</option>
<option>Normal</option>
</select>
<br>
<label>Background Position:</label>
<br>
<select id="emeta[]" name="emeta[]">
<option>Center Top</option>
<option>Center right</option>
<option>Center Bottom</option>
<option>Center Center</option>
<option>Left Top</option>
<option>Left Center</option>
<option>Left Bottom</option>
<option>Right Top</option>
<option>Right Center</option>
<option>Right Bottom</option>
<option>Custom</option>
</select>
<br>
<label>Background Repeat:</label>
<br>
<select id="emeta[]" name="emeta[]">
<option>No Repeat</option>
<option>Repeat</option>
<option>Repeat-X</option>
<option>Repeat-Y</option>
</select>
<label>Value:</label><input size="20" type="text" value="<?php echo esc_attr( $custom_stored_meta1); ?>" name="emetad[]" id="emetad[]">
</li>
<?php
}
function custom_meta1_save($post_id){
//checks save status
$is_autosave = wp_is_post_autosave( $post_id);
$is_revision = wp_is_post_revision( $post_id);
$is_valid_nonce = ( isset( $_POST[ 'custom_meta1_nonce' ] ) && wp_verify_nonce( $_POST['custom_meta1_nonce' ],basename( __FILE__)) ) ? 'true': 'false';
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return;
}
//Exit scripts depending on save status
if( $is_autosave || $is_revision || !$is_valid_nonce ){
return;
}
if( isset( $_POST['drop_down'] ) ){
update_post_meta( $post_id , 'drop_down', sanitize_text_field( $_POST[ 'drop_down'] ) );
}
}
add_action('save_post', 'custom_meta1_save');
本文标签:
版权声明:本文标题:metabox - how to Add Meta Box with featured image settings and To Edit Post Screen For Inline Styles (css box)? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744659994a2618185.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论