/ Published in: PHP
Additional option for Wordpress post (year in this case). You can get it's content in template file by:
`
`
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * Date field * */ /** * Display the metabox */ function date_custom_metabox() { global $post; $year = get_post_meta( $post->ID, 'year', true ); ?> <p><label for="startdate">Rok:</label><br /> <input id="startdate" size="37" name="year" class="event-date" value="<?php if( $year) { echo $year; } ?>" /></label></p> <?php } /** * Process the custom metabox fields */ function save_custom_date( $post_id ) { global $post; if( $_POST ) { update_post_meta( $post->ID, 'year', $_POST['year'] ); } } // Add action hooks. Without these we are lost add_action( 'admin_init', 'add_custom_metabox' ); add_action( 'save_post', 'save_custom_date' ); /** * Add meta box */ function add_custom_metabox() { add_meta_box( 'custom-metabox', 'Year', 'date_custom_metabox', 'post', 'normal', 'high' ); }