I have created a custom post type for events. Now within events post type I have created 2 categories. One is ‘event’ and another one is ‘workshop’.
The ‘event’ category post url looks like
http://www.test.com/news-events/events/event-1/
and the ‘workshop’ category url looks like same as ‘event’
http://www.test.com/news-events/events/test-5555/
Now how can I change the workshop category url to
http://www.test.com/news-events/workshops/test-5555/
The custom post type code is
function create_event_post_type() { // this is our custom function
register_post_type( 'bp_events', // this is the post type we're going to be referring to in our code etc. bespoke name.
array( // set some global parameters for the admin section, mainly text and buttons etc
'labels' => array(
'name' => __( 'Events' ),
'singular_name' => __( 'Event' ),
'add_new' => __( 'Add Event' ),
'add_new_item' => __( 'Add Event' ),
'edit' => __( 'Edit Event' ),
'edit_item' => __( 'Edit Event' ),
'new_item' => __( 'New Event' ),
'view' => __( 'View Event' ),
'view_item' => __( 'View Event' ),
'search_items' => __( 'Search Events' ),
'not_found' => __( 'No Events found' ),
'not_found_in_trash' => __( 'No Events found in Trash' ),
'parent' => __( 'Parent Event' ),
'description' => __( 'A custom post type that allows admin to add a repository of Events to the website.' ) // not sure where this appears but it's here for good measure!
),
'public' => true, // visible to the public
'menu_icon' => bp_events_DIR_URL . 'bp_events.png', // set the icon to appear next to the option in the admin menu
'supports' => array( 'title', 'editor', 'page-attributes', 'revisions', 'thumbnail'), // activate these elements on the custom page. could also include 'excerpt' etc. use 'editor' to include the main editor window, 'revisions' etc
'rewrite' => array( 'slug' => 'news-events/events', 'with_front' => true ), // remove any heirarchical slug in the url that precedes ours and replace with this
'can_export' => true, // we will allow these event pages to be included in a wordpress export in the admin section
'menu_position' => 6,
'hierachical' => true
)
);
}
add_action( 'init', 'create_event_post_type' );
And the taxonomy code is
function bp_events_tax(){
// define taxonomy labels
$labels = array(
'name' => __( 'Category', 'taxonomy general name' ),
'singular_name' => __( 'Associated Categories', 'taxonomy singular name' ),
'search_items' => __( 'Search Categories' ),
'all_items' => __( 'All Categories' ),
'parent_item' => __( 'Parent Category' ),
'parent_item_colon' => __( 'Parent Category:' ),
'edit_item' => __( 'Edit Category' ),
'update_item' => __( 'Update Category' ),
'add_new_item' => __( 'Add New Category' ),
'new_item_name' => __( 'New Category' ),
'menu_name' => __( 'Categories' ),
);
// now create the taxonomy itself
register_taxonomy(
'event-category', // give the taxonomy a slug/name
'bp_events', // assocoate the taxonomy with a cpt
array(
'label' => __('Categories'),
'labels' => $labels,
'sort' => true,
'hierarchical' => true,
'args' => array('orderby' => 'term_order'),
'rewrite' => array('slug' => 'events')
)
);
// repeat both blocks for next taxonomy
}
add_action( 'init', 'bp_events_tax' );
Any help is highly appreciated. Thanks in advance.