/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
add_action('init', 'press_post_type'); function press_post_type() { //step 1: create custom post type $labels = array( 'name' => _x('Press', 'Press'), 'singular_name' => _x('Press', 'Press'), 'add_new' => _x('Add New', 'Press'), 'add_new_item' => __('Add New Press'), 'edit_item' => __('Edit Press'), 'new_item' => __('New Press'), 'all_items' => __('All Press'), 'view_item' => __('View Press'), 'search_items' => __('Search Press'), 'not_found' => __('No Press found'), 'not_found_in_trash' => __('No Press found in Trash'), 'parent_item_colon' => '', 'menu_name' => 'Press' ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => true, 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => null, 'supports' => array( 'title', 'editor', 'author', 'thumbnail' ) ); register_post_type('press',$args); add_action("admin_init", "press_meta"); function press_meta(){ add_meta_box("press_info_meta", "Press", "press_meta_data", "press", "side", "low"); } function press_meta_data() { global $post; $custom = get_post_custom($post->ID); $link = $custom["link"][0]; ?> <p><label>link:</label> <input type="text" name="link" value="<?php echo $link; ?>" /></p> <?php } add_action('save_post', 'save_press'); function save_press(){ global $post; return $post->ID; } update_post_meta($post->ID, "link", $_POST["link"]); } }