/ Published in: PHP
Place into fucntions.php
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/******* CUSTOM POST TYPE: SENIOR LEADERS *********/ add_action('init', 'sl_register'); function sl_register() { $args = array( 'label' => __('Senior Leaders'), 'singular_label' => __('Senior Leader'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => true, 'supports' => array('title', 'thumbnail') ); register_post_type( 'senior-leader' , $args ); } add_action("admin_init", "sl_admin_init"); add_action('save_post', 'save_sl_meta'); function sl_admin_init(){ add_meta_box("sl_meta", "Senior Leader Options", "sl_meta_options", "senior-leader", "normal", "core"); } function sl_meta_options(){ global $post; $custom = get_post_custom($post->ID); $sl_suffix = $custom["sl_suffix"][0]; $sl_jobtitle = $custom["sl_jobtitle"][0]; ?> <div style="float:left;padding:5px 15px;"> <label for="sl_suffix">Suffix </label> <input type="text" name="sl_suffix" size="20" autocomplete="on" value="<?php echo $sl_suffix; ?>"> </div> <div style="float:left;padding:5px 15px;"> <label for="sl_jobtitle">Job Title </label> <input type="text" name="sl_jobtitle" size="30" autocomplete="on" value="<?php echo $sl_jobtitle; ?>"> </div> <p> </p> <p> </p> <?php } function save_sl_meta(){ global $post; update_post_meta($post->ID, "sl_suffix", $_POST["sl_suffix"]); update_post_meta($post->ID, "sl_jobtitle", $_POST["sl_jobtitle"]); } add_filter("manage_edit-senior-leader_columns", "sl_edit_columns"); add_action("manage_posts_custom_column", "sl_custom_columns"); function sl_edit_columns($columns){ "cb" => "<input type=\"checkbox\" />", "title" => "Name", "sl_suffix" => "Suffix", "sl_jobtitle" => "Job Title", "sl_image" => "Featured Image" ); return $columns; } function sl_custom_columns($column){ global $post; switch ($column) { case "sl_suffix": $custom = get_post_custom(); echo $custom["sl_suffix"][0]; break; case "sl_jobtitle": $custom = get_post_custom(); echo $custom["sl_jobtitle"][0]; break; case "sl_image": $sl_thumb = get_thumbnail($post->ID,"60","75"); echo "<img src=\"". $sl_thumb ."\" />"; break; } }