Create Custom post type in wordpress

Posted: January 30, 2013 in Wordpress

Paste this code function.php

function post_type_discog() {

register_post_type(‘discography’,
array(
‘labels’ => array(
‘name’ => __( ‘Discography’ ),
‘singular_name’ => __( ‘Discography’ ),
‘add_new’ => __( ‘Add New’ ),
‘add_new_item’ => __( ‘Add New Discography’ ),
‘edit’ => __( ‘Edit’ ),
‘edit_item’ => __( ‘Edit Discography’ ),
‘new_item’ => __( ‘New Discography’ ),
‘view’ => __( ‘View Discography’ ),
‘view_item’ => __( ‘View Discography’ ),
‘search_items’ => __( ‘Search Discographys’ ),
‘not_found’ => __( ‘No Discographys found’ ),
‘not_found_in_trash’ => __( ‘No Discographys found in Trash’ ),
‘parent’ => __( ‘Parent Discography’ ),
),
‘public’ => true,
‘show_ui’ => true,
‘exclude_from_search’ => true,
‘hierarchical’ => true,
‘supports’ => array( ‘title’, ‘editor’, ‘thumbnail’ ),
‘query_var’ => true
)
);
}
add_action(‘init’, ‘post_type_discog’);

add_action( ‘init’, ‘create_discog_taxonomies’, 0 );

function create_discog_taxonomies()
{
// Add new taxonomy, make it hierarchical (like categories)
$labels = array(
‘name’ => _x( ‘Recordings’, ‘taxonomy general name’ ),
‘singular_name’ => _x( ‘Recording’, ‘taxonomy singular name’ ),
‘search_items’ =>  __( ‘Search Recordings’ ),
‘popular_items’ => __( ‘Popular Recordings’ ),
‘all_items’ => __( ‘All Recordings’ ),
‘parent_item’ => __( ‘Parent Recording’ ),
‘parent_item_colon’ => __( ‘Parent Recording:’ ),
‘edit_item’ => __( ‘Edit Recording’ ),
‘update_item’ => __( ‘Update Recording’ ),
‘add_new_item’ => __( ‘Add New Recording’ ),
‘new_item_name’ => __( ‘New Recording Name’ ),
);
register_taxonomy(‘recordings’,array(‘discography’), array(
‘hierarchical’ => true,
‘labels’ => $labels,
‘show_ui’ => true,
‘query_var’ => true,
‘rewrite’ => array( ‘slug’ => ‘recordings’ ),
));
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s