php - How to use plugin add_meta_box similar using in wp-admin -
i creating form in front same using in wp-admin.
there meta boxes using .
i want konw how can use meta box in front page.
right using
do_action( 'do_meta_boxes', $post_type, 'normal', $post );
but it's not working $wp_meta_boxes; null in front end.
how call boxes in front end.
thanks in advance.
i think meta boxes meant administrative interface , corresponding actions fired in dashboard. instead suggest use normal form, in example below (use code in page template). note must sanitize data comming form before saving database!
<?php // submit form if(isset($_post['submit_form'])){ // important: sanitize , validate post values here // update post meta update_post_meta(get_the_id(), 'firstname', $_post['firstname']); update_post_meta(get_the_id(), 'lastname', $_post['lastname']); } ?> <?php // post meta $firstname = get_post_meta(get_the_id(), 'firstname', true); $lastname = get_post_meta(get_the_id(), 'lastname', true); ?> <form action="#" method="post"> first name:<br> <input type="text" name="firstname" value="<?php echo esc_attr($firstname);?>"> <br> last name:<br> <input type="text" name="lastname" value="<?php echo esc_attr($lastname);?>"> <button type="submit" name="submit_form" value="1">submit</button> </form>
Comments
Post a Comment