It includes the custom post taxonomy and supports (like thumbnail, categories, and excerpt)
define('LW_TEXT_DOMAIN', 'lightweight');
$slug = 'portfolio';
$labels =
array(
// The plural form of the name of your post type.
'name' => __( 'Portfolio',LW_TEXT_DOMAIN),
// The singular form of the name of your post type.
'singular_name' => __('Portfolio',LW_TEXT_DOMAIN),
// The rewrite of the post type
'rewrite' =>
array(
// prepends our post type with this slug
'slug' => __( 'portfolio' ,LW_TEXT_DOMAIN)
),
// The menu item for adding a new post.
'add_new' => _x('Add Item', 'portfolio',LW_TEXT_DOMAIN),
// The header shown when editing a post.
'edit_item' => __('Edit Portfolio Item',LW_TEXT_DOMAIN),
// Shown in the favourites menu in the admin header.
'new_item' => __('New Portfolio Item',LW_TEXT_DOMAIN),
// Shown alongside the permalink on the edit post screen.
'view_item' => __('View Portfolio',LW_TEXT_DOMAIN),
// Button text for the search box on the edit posts screen.
'search_items' => __('Search Portfolio',LW_TEXT_DOMAIN),
// Text to display when no posts are found through search in the admin.
'not_found' => __('No Portfolio Items Found',LW_TEXT_DOMAIN),
// Text to display when no posts are in the trash.
'not_found_in_trash' => __('No Portfolio Items Found In Trash',LW_TEXT_DOMAIN),
// Used as a label for a parent post on the edit posts screen. Only useful for hierarchical post types.
'parent_item_colon' => ''
);
// Set Up The Arguements
$args =
array(
// Pass The Array Of Labels
'labels' => $labels,
// Display The Post Type To Admin
'public' => true,
// Allow Post Type To Be Queried
'publicly_queryable' => true,
// Build a UI for the Post Type
'show_ui' => true,
// Use String for Query Post Type
'query_var' => true,
// Rewrite the slug
'rewrite' => true,
// Set type to construct arguements
'capability_type' => 'post',
// Disable Hierachical - No Parent
'hierarchical' => false,
// Set Menu Position for where it displays in the navigation bar
'menu_position' => 200,
// Allow the portfolio to support a Title, Editor, Thumbnail
'supports' =>
array(
'title',
'editor',
'thumbnail'
) ,
'rewrite' =>
array(
// prepends our post type with this slug
'slug' => $slug
),
);
// Register The Post Type
register_post_type(__( 'portfolio' ,LW_TEXT_DOMAIN),$args);
// Register the Taxonomy
register_taxonomy(__( "filter" ,LW_TEXT_DOMAIN),
// Assign the taxonomy to be part of the portfolio post type
array(__( "portfolio" ,LW_TEXT_DOMAIN)),
// Apply the settings for the taxonomy
array(
"hierarchical" => true,
"label" => __( "Categories" ,LW_TEXT_DOMAIN),
"singular_label" => __( "Categories" ,LW_TEXT_DOMAIN),
"rewrite" => array(
'slug' => 'filter',
'hierarchical' => true
)
)
);
add_post_type_support( 'portfolio', 'excerpt' );