Created
June 23, 2015 15:24
-
-
Save jandrodev/11a9246766c182bbbc60 to your computer and use it in GitHub Desktop.
Gestión de Meta Box básica en posts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'add_meta_boxes', 'post_options' ); | |
add_action( 'save_post', 'post_options_save_data' ); | |
function post_options() { | |
add_meta_box('post_meta_box_mobile', 'Título de la sección', 'post_meta_box_mobile', 'post', 'normal', 'high'); | |
} | |
function post_meta_box_mobile($post) { | |
$id = $post->ID; | |
$availability = get_post_meta($id,"_mobile_availability",true); | |
?> | |
<table class="form-table"> | |
<tbody> | |
<tr> | |
<th><label for="availability">Availability</label></th> | |
<td><input type="text" id="availability" name="availability" value="<?php echo $availability; ?>" /></td> | |
</tr> | |
</tbody> | |
</table> | |
<?php | |
} | |
function post_options_save_data($post_id) { | |
if (isset($_POST['availability'])) { | |
update_post_meta($post_id, '_mobile_availability', $_POST['availability']); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment