Posted By

jamiebrwr on 08/13/10


Tagged

wordpress


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

jamalmohamed
booski


Custom Post Type: Board Of Directors


 / Published in: PHP
 

Place into fucntions.php

  1. /******* CUSTOM POST TYPE: BOARD OF DIRECTORS *********/
  2.  
  3. add_action('init', 'bod_register');
  4.  
  5. function bod_register() {
  6. $args = array(
  7. 'label' => __('Board of Directors'),
  8. 'singular_label' => __('Board Member'),
  9. 'public' => true,
  10. 'show_ui' => true,
  11. 'capability_type' => 'post',
  12. 'hierarchical' => false,
  13. 'rewrite' => true,
  14. 'supports' => array('title', 'thumbnail')
  15. );
  16.  
  17. register_post_type( 'board-member' , $args );
  18. }
  19.  
  20. add_action("admin_init", "bod_admin_init");
  21. add_action('save_post', 'save_bod_meta');
  22.  
  23. function bod_admin_init(){
  24. add_meta_box("bod_meta", "Board Member Options", "bod_meta_options", "board-member", "normal", "core");
  25. }
  26.  
  27. function bod_meta_options(){
  28. global $post;
  29. $custom = get_post_custom($post->ID);
  30. $bod_suffix = $custom["bod_suffix"][0];
  31. $bod_position = $custom["bod_position"][0];
  32.  
  33. ?>
  34. <div style="float:left;padding:5px 15px;">
  35. <label for="bod_suffix">Suffix </label>
  36. <input type="text" name="bod_suffix" size="20" autocomplete="on" value="<?php echo $bod_suffix; ?>">
  37. </div>
  38. <div style="float:left;padding:5px 15px;">
  39. <label for="bod_position">Position </label>
  40. <input type="text" name="bod_position" size="30" autocomplete="on" value="<?php echo $bod_position; ?>">
  41. </div>
  42. <p>&nbsp;</p>
  43. <p>&nbsp;</p>
  44. <?php
  45. }
  46.  
  47. function save_bod_meta(){
  48. global $post;
  49. update_post_meta($post->ID, "bod_suffix", $_POST["bod_suffix"]);
  50. update_post_meta($post->ID, "bod_position", $_POST["bod_position"]);
  51. }
  52.  
  53. add_filter("manage_edit-board-member_columns", "bod_edit_columns");
  54. add_action("manage_posts_custom_column", "bod_custom_columns");
  55.  
  56. function bod_edit_columns($columns){
  57. $columns = array(
  58. "cb" => "<input type=\"checkbox\" />",
  59. "title" => "Name",
  60. "bod_suffix" => "Suffix",
  61. "bod_position" => "Position",
  62. "bod_image" => "Featured Image"
  63. );
  64.  
  65. return $columns;
  66. }
  67.  
  68. function bod_custom_columns($column){
  69. global $post;
  70. switch ($column)
  71. {
  72. case "bod_suffix":
  73. $custom = get_post_custom();
  74. echo $custom["bod_suffix"][0];
  75. break;
  76. case "bod_position":
  77. $custom = get_post_custom();
  78. echo $custom["bod_position"][0];
  79. break;
  80. case "bod_image":
  81. $sl_thumb = get_thumbnail($post->ID,"60","75");
  82. echo "<img src=\"". $sl_thumb ."\" />";
  83. break;
  84. }
  85. }

Report this snippet  

You need to login to post a comment.