Customize category URL
-
I’ve searched around and have not found the answers im looking for. By default I have:
– example.com/blog (blog archive)
– example.com/blog/category/announcements (single taxonomy view)Now I’ve created a custom post type & taxonomy (categories) to go along with it, but I’m having trouble mirroring the blog’s URL structure. For example my goal is:
– example.com/talks (blog archive)
– example.com/talks/category/support (single taxonomy view)Here is what I have so far:
function uc_add_talks_post_type() { $talks_labels = array( 'name' => 'Talks', 'singular_name' => 'Talk', 'all_items' => 'All Talks', 'add_new' => 'Add new', 'add_new_item' => 'Add new Talk', 'edit_item' => 'Edit Talk', 'new_item' => 'New Talk', 'view_item' => 'View Talk', 'search_items' => 'Search Talks', 'not_found' => 'No Talks found', 'not_found_in_trash' => 'No Talks found in Trash', ); $talks_args = array( 'labels' => $talks_labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'menu_position' => 5, 'rewrite' => array( 'slug' => 'talks', 'with_front' => false ), 'has_archive' => 'talks', ); $talks_cat_args = array( 'hierarchical' => true, 'labels' => array( 'name' => __( 'Talk categories', 'jointstheme' ), 'singular_name' => __( 'Talk category', 'jointstheme' ), 'search_items' => __( 'Search talk categories', 'jointstheme' ), 'all_items' => __( 'All talk categories', 'jointstheme' ), 'parent_item' => __( 'Parent talk category', 'jointstheme' ), 'parent_item_colon' => __( 'Parent talk category:', 'jointstheme' ), 'edit_item' => __( 'Edit talk category', 'jointstheme' ), 'update_item' => __( 'Update talk category', 'jointstheme' ), 'add_new_item' => __( 'Add new talk category', 'jointstheme' ), 'new_item_name' => __( 'New talk category name', 'jointstheme' ) ), 'show_admin_column' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'talks', 'with_front' => false ), ); register_post_type( 'uc_talks', $talks_args ); register_taxonomy( 'uc_talks_cat', array('uc_talks'), $talks_cat_args ); } add_action( 'init', 'uc_add_talks_post_type');
(I tried to use the proper terminology here, taxonomy vs. category, archive vs. listing etc. But feel free to correct that if I messed up).
- The topic ‘Customize category URL’ is closed to new replies.