/ Published in: PHP
Place into fucntions.php
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/******* CUSTOM POST TYPE: BOARD OF DIRECTORS *********/ add_action('init', 'bod_register'); function bod_register() { $args = array( 'label' => __('Board of Directors'), 'singular_label' => __('Board Member'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => true, 'supports' => array('title', 'thumbnail') ); register_post_type( 'board-member' , $args ); } add_action("admin_init", "bod_admin_init"); add_action('save_post', 'save_bod_meta'); function bod_admin_init(){ add_meta_box("bod_meta", "Board Member Options", "bod_meta_options", "board-member", "normal", "core"); } function bod_meta_options(){ global $post; $custom = get_post_custom($post->ID); $bod_suffix = $custom["bod_suffix"][0]; $bod_position = $custom["bod_position"][0]; ?> <div style="float:left;padding:5px 15px;"> <label for="bod_suffix">Suffix </label> <input type="text" name="bod_suffix" size="20" autocomplete="on" value="<?php echo $bod_suffix; ?>"> </div> <div style="float:left;padding:5px 15px;"> <label for="bod_position">Position </label> <input type="text" name="bod_position" size="30" autocomplete="on" value="<?php echo $bod_position; ?>"> </div> <p> </p> <p> </p> <?php } function save_bod_meta(){ global $post; update_post_meta($post->ID, "bod_suffix", $_POST["bod_suffix"]); update_post_meta($post->ID, "bod_position", $_POST["bod_position"]); } add_filter("manage_edit-board-member_columns", "bod_edit_columns"); add_action("manage_posts_custom_column", "bod_custom_columns"); function bod_edit_columns($columns){ "cb" => "<input type=\"checkbox\" />", "title" => "Name", "bod_suffix" => "Suffix", "bod_position" => "Position", "bod_image" => "Featured Image" ); return $columns; } function bod_custom_columns($column){ global $post; switch ($column) { case "bod_suffix": $custom = get_post_custom(); echo $custom["bod_suffix"][0]; break; case "bod_position": $custom = get_post_custom(); echo $custom["bod_position"][0]; break; case "bod_image": $sl_thumb = get_thumbnail($post->ID,"60","75"); echo "<img src=\"". $sl_thumb ."\" />"; break; } }