Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.64 KB | None | 0 0
  1. add_action('init', 'create_portfolio');
  2.  
  3. function create_portfolio() {
  4.  
  5.     $labels = array(
  6.         'name' => __('Portfolio', 'post type general name'),
  7.         'singular_name' => __('Project', 'post type singular name'),
  8.         'add_new' => __('Add New', 'portfolio item'),
  9.         'add_new_item' => __('Add New Project'),
  10.         'edit_item' => __('Edit Project'),
  11.         'new_item' => __('New Project'),
  12.         'view_item' => __('View Project'),
  13.         'search_items' => __('Search Projects'),
  14.         'not_found' =>  __('Nothing found'),
  15.         'not_found_in_trash' => __('Nothing found in Trash'),
  16.         'parent_item_colon' => ''
  17.     );
  18.  
  19.     $args = array(
  20.         'labels' => $labels,
  21.         'public' => true,
  22.         'publicly_queryable' => true,
  23.         'show_ui' => true,
  24.         'query_var' => true,
  25.         'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',
  26.         'rewrite' => true,
  27.         'capability_type' => 'post',
  28.         'hierarchical' => false,
  29.         'menu_position' => null,
  30.         'supports' => array('title','editor','thumbnail')
  31.       );
  32.  
  33.     register_post_type( 'portfolio' , $args );
  34. }
  35.  
  36. register_taxonomy("Skills", array("portfolio"), array("hierarchical" => true, "label" => "Skills", "singular_label" => "Skill", "rewrite" => true));
  37.  
  38. add_action("admin_init", "admin_init");
  39.  
  40. function admin_init(){
  41.   add_meta_box("website_url", "Website URL", "website_url", "portfolio", "side", "low");
  42.   add_meta_box("special_notes", "Special Notes", "special_notes", "portfolio", "side", "low");
  43. }
  44.  
  45. function website_url(){
  46.   global $post;
  47.   $custom = get_post_custom($post->ID);
  48.   $website_url = $custom["website_url"][0];
  49.   ?>
  50.   <label>Website URL:</label>
  51.   <input name="website_url" value="<?php echo $website_url; ?>" />
  52.   <?php
  53. }
  54.  
  55. function special_notes() {
  56.   global $post;
  57.   $custom = get_post_custom($post->ID);
  58.   $special_notes = $custom["special_notes"][0];
  59.   ?>
  60.   <label>Special Notes:</label>
  61.   <input name="special_notes" value="<?php echo $special_notes; ?>" />
  62.   <?php
  63. }
  64.  
  65. add_action('save_post', 'save_details');
  66.  
  67. function save_details(){
  68.   global $post;
  69.  
  70.   update_post_meta($post->ID, "website_url", $_POST["website_url"]);
  71.   update_post_meta($post->ID, "special_notes", $_POST["special_notes"]);
  72. }
  73.  
  74. add_action("manage_posts_custom_column",  "portfolio_custom_columns");
  75. add_filter("manage_edit-portfolio_columns", "portfolio_edit_columns");
  76.  
  77. function portfolio_edit_columns($columns){
  78.   $columns = array(
  79.     "cb" => "<input type=\"checkbox\" />",
  80.     "title" => "Project Title",
  81.     "description" => "Description",
  82.   );
  83.  
  84.   return $columns;
  85. }
  86. function portfolio_custom_columns($column){
  87.   global $post;
  88.  
  89.   switch ($column) {
  90.     case "description":
  91.       the_excerpt();
  92.       break;
  93.   }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement