/ Published in: PHP
Enables you to add a custom panel in the admin post section for a custom field input
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php // Add Custom Inputs add_action("admin_init", "admin_init"); add_action("save_post", "save_post"); function admin_init() { add_meta_box( "sectionID", "Section Name", "add_fields", "post-type", "side", "low" ); } function add_fields() { global $post; $custom = get_post_custom( $post->ID ); $fieldName = $custom["fieldName"][0]; wp_nonce_field("metaNonce", 'metaNonce'); ?> <label>Field Name:</label> <input type="text" size="31" name="fieldName" value="<?php echo $fieldName; ?>" /> <?php } function save_post() { global $post; if ( wp_verify_nonce( $_POST['metaNonce'], 'metaNonce' ) ) { update_post_meta( $post->ID, "fieldName", $_POST["fieldName"] ); } } ?>