Working With Custom Post Types

Getting started

WordPress can hold and display many different types of content. Internally, these are all stored in the same place, in the wp_posts table. These are differentiated by a column called post_type. WordPress 3.0 gives you the capability to add your own custom post types and to use them in different ways. Adding a custom type to WordPress is done via the register_post_type function. This function allows you to define the post type and how it operates within WordPress.

Working with custom post types considered that you'll work with framework/functions/theme.php library inside function miss_post_types().

function miss_post_types() {
	register_post_type( 'slug', array() );
}

Here is example code:

register_post_type('portfolio', array(
	'labels' => array(
		'name' => _x('Portfolios', 'post type general name', MISS_ADMIN_TEXTDOMAIN ),
		'singular_name' => _x('Portfolio', 'post type singular name', MISS_ADMIN_TEXTDOMAIN ),
		'add_new' => _x('Add New', 'portfolio', MISS_ADMIN_TEXTDOMAIN ),
		'add_new_item' => __('Add New Portfolio', MISS_ADMIN_TEXTDOMAIN ),
		'edit_item' => __('Edit Portfolio', MISS_ADMIN_TEXTDOMAIN ),
		'new_item' => __('New Portfolio', MISS_ADMIN_TEXTDOMAIN ),
		'view_item' => __('View Portfolio', MISS_ADMIN_TEXTDOMAIN ),
		'search_items' => __('Search Portfolios', MISS_ADMIN_TEXTDOMAIN ),
		'not_found' =>  __('No portfolios found', MISS_ADMIN_TEXTDOMAIN ),
		'not_found_in_trash' => __('No portfolios found in Trash', MISS_ADMIN_TEXTDOMAIN ), 
		'parent_item_colon' => ''
	),
	'singular_label' => __('Portfolio', MISS_ADMIN_TEXTDOMAIN ),
	'public' => true,
	'exclude_from_search' => false,
	'show_ui' => true,
	'capability_type' => 'post',
	'hierarchical' => false,
	'rewrite' => array( 'with_front' => false ),
	'menu_icon' => THEME_ADMIN_ASSETS_URI . '/images/portfolio.png',
	'query_var' => false,
	'publicly_queryable' => true,
	'can_export' => true,
	'rewrite' => true,
	'has_archive' => true,
	'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'comments' )
));