Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 27th, 2011  |  syntax: None  |  size: 2.25 KB  |  views: 289  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. add_action( 'admin_print_styles-post-new.php', 'portfolio_admin_style', 11 );
  3. add_action( 'admin_print_styles-post.php', 'portfolio_admin_style', 11 );
  4.  
  5. function portfolio_admin_style() {
  6.     global $post_type;
  7.     if( 'portfolio' == $post_type )
  8.         wp_enqueue_style( 'portfolio-admin-style', get_stylesheet_directory_uri() . '/styles/portfolio-admin.css' );
  9. }
  10.  
  11.  
  12. add_action('init', 'create_portfolio');
  13.         function create_portfolio() {
  14.         $portfolio_args = array(
  15.                 'label' => __('Portfolio'),
  16.                 'singular_label' => __('Portfolio'),
  17.                 'public' => true,
  18.                 'show_ui' => true,
  19.                 'capability_type' => 'post',
  20.                 'hierarchical' => false,
  21.                 'rewrite' => true,
  22.                 'supports' => array('title', 'editor', 'thumbnail')
  23.         );
  24.         register_post_type('portfolio',$portfolio_args);
  25.         }
  26.  
  27. // Input fields
  28. add_action("admin_init", "add_portfolio");
  29.         add_action('save_post', 'update_website_url');
  30.         function add_portfolio(){
  31.                 add_meta_box("portfolio_details", "Portfolio Options", "portfolio_options", "portfolio", "normal", "low");
  32.         }
  33.         function portfolio_options(){
  34.                 global $post;
  35.                 $custom = get_post_custom($post->ID);
  36.                 $website_url = $custom["website_url"][0];
  37.                 $port_excerpt = $custom["port_excerpt"][0];
  38. ?>
  39.  
  40.         <div id="portfolio-options">
  41.                 <label>Website URL:</label><input name="website_url" value="<?php echo $website_url; ?>" />
  42.                 <label>Excerpt:</label><input name="port_excerpt" value="<?php echo $port_excerpt; ?>" />              
  43.         </div><!--end portfolio-options-->  
  44. <?php
  45.         }
  46.         function update_website_url(){
  47.                 global $post;
  48.                 update_post_meta($post->ID, "website_url", $_POST["website_url"]);
  49.                 update_post_meta($post->ID, "port_excerpt", $_POST["port_excerpt"]);
  50.         }
  51.  
  52. add_filter("manage_edit-portfolio_columns", "portfolio_edit_columns");
  53. add_action("manage_posts_custom_column",  "portfolio_columns_display");
  54.  
  55. function portfolio_edit_columns($portfolio_columns){
  56.         $portfolio_columns = array(
  57.                 "cb" => "<input type=\"checkbox\" />",
  58.                 "title" => "Project Title",
  59.                 "description" => "Description",
  60.         );
  61.         return $portfolio_columns;
  62. }
  63.  
  64. function portfolio_columns_display($portfolio_columns){
  65.         switch ($portfolio_columns)
  66.         {
  67.                 case "description":
  68.                         the_excerpt();
  69.                         break;                         
  70.         }
  71. }
  72.  
  73.