Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('init', 'portfolio_register');
- function portfolio_register() {
- $labels = array(
- 'name' => _x('My Portfolio', 'post type general name'),
- 'singular_name' => _x('Portfolio Item', 'post type singular name'),
- 'add_new' => _x('Add New', 'portfolio item'),
- 'add_new_item' => __('Add New Portfolio Item'),
- 'edit_item' => __('Edit Portfolio Item'),
- 'new_item' => __('New Portfolio Item'),
- 'view_item' => __('View Portfolio Item'),
- 'search_items' => __('Search Portfolio'),
- 'not_found' => __('Nothing found'),
- 'not_found_in_trash' => __('Nothing found in Trash'),
- 'parent_item_colon' => ''
- );
- $args = array(
- 'labels' => $labels,
- 'public' => true,
- 'publicly_queryable' => true,
- 'show_ui' => true,
- 'query_var' => true,
- 'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',
- 'rewrite' => true,
- 'capability_type' => 'post',
- 'hierarchical' => false,
- 'menu_position' => null,
- 'supports' => array('title','editor','thumbnail')
- );
- register_post_type( 'portfolio' , $args );
- }
- register_taxonomy("Skills", array("portfolio"), array("hierarchical" => true, "label" => "Skills", "singular_label" => "Skill", "rewrite" => true));
- add_action("admin_init", "admin_init");
- function admin_init(){
- add_meta_box("year_completed-meta", "Year Completed", "year_completed", "portfolio", "side", "low");
- add_meta_box("credits_meta", "Design & Build Credits", "credits_meta", "portfolio", "normal", "low");
- }
- function year_completed(){
- global $post;
- $custom = get_post_custom($post->ID);
- $year_completed = $custom["year_completed"][0];
- ?>
- <label>Year:</label>
- <input name="year_completed" value="<?php echo $year_completed; ?>" />
- <?php
- }
- function credits_meta() {
- global $post;
- $custom = get_post_custom($post->ID);
- $designers = $custom["designers"][0];
- $developers = $custom["developers"][0];
- $producers = $custom["producers"][0];
- ?>
- <p><label>Designed By:</label><br />
- <textarea cols="50" rows="5" name="designers"><?php echo $designers; ?></textarea></p>
- <p><label>Built By:</label><br />
- <textarea cols="50" rows="5" name="developers"><?php echo $developers; ?></textarea></p>
- <p><label>Produced By:</label><br />
- <textarea cols="50" rows="5" name="producers"><?php echo $producers; ?></textarea></p>
- <?php
- }
- add_action('save_post', 'save_details');
- function save_details(){
- global $post;
- update_post_meta($post->ID, "year_completed", $_POST["year_completed"]);
- update_post_meta($post->ID, "designers", $_POST["designers"]);
- update_post_meta($post->ID, "developers", $_POST["developers"]);
- update_post_meta($post->ID, "producers", $_POST["producers"]);
- }
- add_action("manage_posts_custom_column", "portfolio_custom_columns");
- add_filter("manage_edit-portfolio_columns", "portfolio_edit_columns");
- function portfolio_edit_columns($columns){
- $columns = array(
- "cb" => "<input type="checkbox" />",
- "title" => "Portfolio Title",
- "description" => "Description",
- "year" => "Year Completed",
- "skills" => "Skills",
- );
- return $columns;
- }
- function portfolio_custom_columns($column){
- global $post;
- switch ($column) {
- case "description":
- the_excerpt();
- break;
- case "year":
- $custom = get_post_custom();
- echo $custom["year_completed"][0];
- break;
- case "skills":
- echo get_the_term_list($post->ID, 'Skills', '', ', ','');
- break;
- }
- }
- add_theme_support('post-thumbnails');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement