Multi-Level Permalinks on Custom Post Type
-
Hi-
Let’s say I have a custom post type called portfolio, and set it up with the following code.function create_portfolio_post_type() { $portfolio_labels = array( 'name' => 'Projects', 'singular_name' => 'Project', 'add_new' => 'Add New', 'all_items' => 'All Projects', 'add_new_item' => 'Add New Project', 'edit_item' => 'Edit Project', 'new_item' => 'New Project', 'view_item' => 'View project', 'search_items' => 'Search projects', 'not_found' => 'No projects found', 'not_found_in_trash' => 'No projects found in Trash', 'parent_item_colon' => 'Parent Project', 'menu_name' => 'Portfolio' ); $portfolio_definition = array( 'labels' => $portfolio_labels, 'description' => 'Projects', 'public' => true, 'exclude_from_search' => false, 'show_ui' => true, 'show_in_nav_menus' => true, 'show_in_menu' => true, 'show_in_admin_bar' => true, 'menu_position' => 5, 'capability_type' => 'post', 'hierarchical' => true, 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'revisions', 'page-attributes', 'post-formats'), 'taxonomies' => 'project_type', 'has_archive' => true, 'rewrite' => array('slug', 'portfolio'), 'can_export' => true ); register_post_type ('portfolio', $portfolio_definition); } add_action ('init', 'create_portfolio_post_type');
Now let’s say I added a taxonomy to my post type with this code:
function create_portfolio_taxonomy() { $project_type_labels = array( 'name' => 'Project Types', 'singular_name' => 'Project Type', 'search_items' => 'Search Project Types', 'popular_items' => 'Popular Project Types', 'all_items' => 'All Project Types', 'parent_items' => 'Parent Project Type', 'parent_item_colon' => 'Parent Project Type', 'edit_item' => 'Edit Project Type', 'update_item' => 'Update Project Type', 'add_new_item' => 'Add New Project Type', 'new_item_name' => 'New Project Type Name', 'menu_name' => 'Project Types' ); $project_type_definition = array( 'labels' => $project_type_labels, 'public' => true, 'show_in_nav_menus' => true, 'hierarchical' => true, 'rewrite' => array('slug' => 'projects'), 'capabilities' => array('manage_terms', 'edit_terms', 'delete_terms', 'assign_terms') ); register_taxonomy ('project_type', 'portfolio', $project_type_definition ); }
What I want to do is set up my permalink structure so that if someone wants to get to a project, thy can type in:
https://www.example.com/post_type(portfolio)/taxonomy(projects)/(taxonomy_item)animations/video1(post_name)/
and get to the right post.
However, when I use
'rewrite' => array('slug' => 'portfolio/projects')
in my taxonomy register function, the site returns a 404. What can I do to fix this?
Also, yes, I did flush the rewrites.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Multi-Level Permalinks on Custom Post Type’ is closed to new replies.