// CPT portfolio
add_action('init','create_post_type');
add_action('init','create_taxonomies');
function create_post_type() {
$labels = array(
'name' => 'Portfolios',
'singular_name' => 'Portfolio',
'menu_name' => 'Portfolios',
'name_admin_bar' => 'Portfolio',
'add_new' => 'Add New',
'add_new_item' => 'Add New Portfolio',
'new_item' => 'New Portfolio',
'edit_item' => 'Edit Portfolio',
'view_item' => 'View Portfolio',
'all_items' => 'All Portfolios',
'search_items' => 'Search Portfolios',
'parent_item_colon' => 'Parent Portfolio',
'not_found' => 'No Portfolios Found',
'not_found_in_trash' => 'No Portfolios Found in Trash'
);
$args = array(
'labels' => $labels,
'public' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_nav_menus' => true,
'show_in_menu' => true,
'show_in_admin_bar' => true,
'menu_position' => 80,
'menu_icon' => 'dashicons-format-gallery',
'capability_type' => 'post',
'hierarchical' => false,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'comments', 'custom-fields' ),
'has_archive' => true,
'rewrite' => array( 'slug' => 'portfolio' ),
'query_var' => true
);
register_post_type( 'oi_portfolio', $args );
}
function create_taxonomies() {
// Add new taxonomy, make it hierarchical (like categories)
$labels = array(
'name' => 'Portfolio Categories',
'singular_name' => 'Portfolio Category',
'search_items' => 'Search 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',
'menu_name' => 'Portfolio Categories',
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'portfolio_category' ),
);
register_taxonomy('oi_portfolio_categories',array('oi_portfolio'),$args);
// Add new taxonomy, NOT hierarchical (like tags)
$labels = array(
'name' => 'Portfolio Tags',
'singular_name' => 'Portfolio Tag',
'search_items' => 'Portfolio Tags',
'popular_items' => 'Popular Portfolio Tags',
'all_items' => 'All Portfolio Tags',
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => 'Edit Portfolio Tag',
'update_item' => 'Update Portfolio Tag',
'add_new_item' => 'Add New Portfolio Tag',
'new_item_name' => 'New Portfolio Tag Name',
'separate_items_with_commas' => 'Separate Portfolio Tags with commas',
'add_or_remove_items' => 'Add or remove Portfolio Tags',
'choose_from_most_used' => 'Choose from most used Portfolio Tags',
'not_found' => 'No Portfolio Tags found',
'menu_name' => 'Portfolio Tags',
);
$args = array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => 'portfolio_tag' ),
);
register_taxonomy('oi_portfolio_tags','oi_portfolio',$args);
}