This is the code used to initiate the custom post type ‘Events‘:
add_action('init', 'createEvents');
function createEvents(){
// Fire this during init
register_post_type('events', array(
'label' => __('Events'),
'singular_label' => __('Event'),
'add_new_item' => __('Add New Event'),
'edit_item' => __('Edit Event'),
'new_item' => __('New Event'),
'view_item' => __('View Event'),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'show_in_menu' => true,
'menu_position' => 20,
'rewrite' => false,
'show_in_nav_menus' => false,
'supports' => array('title', 'editor', 'author', 'excerpt','eventcategories')
));
}
This is the code used to initiate the custom taxonomy ‘Event Categories‘:
add_action('init','create_event_taxonomies');
function create_event_taxonomies(){
register_taxonomy('eventcategories','events',
array(
'hierarchical' => true,
'label' => 'Event Categories',
'singular_label' => 'Event Category',
'show_ui' => true,
'query_var' => 'events',
'rewrite' => array( 'slug' => 'event-type' ),
));
}