__('Portfolio'),
'labels' => array(
'name' => __( 'Portfolio' ),
'singular_name' => __( 'Portfolio' ),
'add_new' => __( 'Add New Item' ),
'add_new_item' => __( 'Add New Portfolio Item' ),
'edit_item' => __( 'Edit New Portfolio Item' ),
'new_item' => __( 'New New Portfolio Item' ),
'view_item' => __( 'View New Portfolio Item' ),
'search_items' => __( 'Search Portfolio Items' ),
'not_found' => __( 'No portfolio items found' ),
'not_found_in_trash' => __( 'No portfolio items found in Trash' )
),
'menu_position' => 4,
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => true,
'rewrite' => true,
'supports' => array('title','thumbnail','excerpt', 'editor'),
'query_var' => 'portfolio', // This goes to the WP_Query schema
)
);
}
//hook into the init action and call create_book_taxonomies when it fires
add_action( 'init', 'create_portfolio_taxonomies', 0 );
//create taxonomy Portfolio Categories for the post type "portfolio"
function create_portfolio_taxonomies() {
register_taxonomy('pcategory','portfolio',
array (
'label' => 'Portfolio Categories',
// Add new taxonomy, make it hierarchical (like categories)
'labels' => array (
'name' => _x( 'Categories', 'portfolio' ),
'singular_name' => _x( 'Portfolio Category', 'portfolio' ),
'search_items' => __( 'Search Portfolio Categories' ),
'popular_items' => __( 'Popular Portfolio Categories' ),
'all_items' => __( 'All Portfolio Categories' ),
'parent_item' => __( 'Parent Portfolio Category' ),
'parent_item_colon' => __( 'Parent Portfolio Category:' ),
'edit_item' => __( 'Edit Portfolio Category' ),
'update_item' => __( 'Update Portfolio Category' ),
'add_new_item' => __( 'Add New Portfolio Category' ),
'new_item_name' => __( 'New Portfolio Category Name' ),
),
'hierarchical' =>true,
'show_ui' => true,
'show_tagcloud' => true,
'rewrite' => true,
'query_var' => true,
'public'=>true)
);
}
add_filter("manage_edit-portfolio_columns", "portfolio_edit_columns");
add_action("manage_portfolio_custom_column", "portfolio_columns_display");
function portfolio_edit_columns($portfolio_columns){
$portfolio_columns = array(
'cb' => '',
'title' => __( 'Project Title' ),
'description' => __( 'Description' ),
'pcategory' => __( 'Portfolio Categories' ),
'author' => __( 'Author' ),
'date' => __( 'Date' ),
'thumbnail' => __('Thumbnail'),
);
return $portfolio_columns;
}
function portfolio_columns_display($portfolio_columns){
global $post;
if( get_post_type() == 'portfolio')://here goes the name of custom post
switch ($portfolio_columns)
{
case "description":
the_excerpt();
break;
case "pcategory":
echo get_the_term_list( $post->ID, 'pcategory', '', ', ', '' );
break;
}
endif;
}
add_action( 'admin_head', 'wpt_portfolio_icons' );
function wpt_portfolio_icons() {
?>