Set your taxonomy slug to taxonomy_name
and in your post type set the slug to taxonomy_name/%taxonomy_name_term%
and flush rewrite rules (simply by going to permalink settings panel in the admin) And after that WordPress will be able to handle /taxonomy_name/%taxonomy_name_term%/post-name/
URLs.
So all that is left to do is tell WordPress what %taxonomy_name_term%
means and for that just add this function to your theme’s functions.php file:
add_filter('post_type_link', 'events_permalink_structure', 10, 4);
function events_permalink_structure($post_link, $post, $leavename, $sample)
{
if ( false !== strpos( $post_link, '%taxonomy_name_term%' ) ) {
$event_type_term = get_the_terms( $post->ID, 'TAXONOMY_NAME' );
$post_link = str_replace( '%taxonomy_name_term%', array_pop( $event_type_term )->slug, $post_link );
}
return $post_link;
}
Make sure you replace TAXONOMY_NAME
with the actual name of the taxonomy.
Related Posts:
- WordPress Rewrite Rules for Custom Post Type and Taxonomy
- How to modify URL structures in custom post types and taxonomies or terms
- Archive page with multiple taxonomies rewrite
- Taxonomy archives based on Custom Post Type
- Permalink rewrite with custom post type and custom taxonomy
- WP Rewrite Rules – Custom post type & taxonomy
- Remove base slug in CPT & CT, use CT in permalink
- Custom Permalink Tag breaks Pagination
- Custom Permalink for Taxonimie and Custom Post Type
- how to get archive urls with same origin for custom types and terms?
- Permalink Structure CPT With Custom Taxonomy Fails
- Remove url rewrites for registered taxonomies
- Can’t get custom rewrite tag, query var, permastruct (permalink structure), and rewrite rule to work properly together
- Customize Custom Post Type URL
- How do I change the custom taxonomy slug to be the same as the custom post type slug?
- Custom taxonomy rewrite with query var returns %2F in URL
- WP Rewrite Rule Issue while using Custom post type & taxonomy
- Custom Permalinks with CPT and Hierarchical Taxonomies
- How to get list of taxonomy slugs ordered parents>childs?
- Permalink structure with custom taxonomies and custom post type like /parent-tax/child-tax/custom-post-type-name (with no base name)
- Combine multiple CPT names to create valid permalinks
- How to rewrite custom taxonomy term archive to use THE SAME SLUG/front as CPT
- WordPress custom permalink and archive link for custom post type
- How to rewrite the post slug of a custom post type post
- Modifying rewrite rules to use /category//
- Custom taxonomy and post type rewrite rules
- Remove cpt slug from url and use custom taxonomy instead breaks all other cpt
- How to properly set the rewrite rules for this case?
- Change CPT permalink to use the category
- How to fix 404 on post after prepending Custom Post Type url with Custom Taxonomy Term slug
- Redirect Custom Post Type from Child Taxonomies
- How to build overlapping custom post_type and taxonomy rewrites without conflicts?
- Custom Post Type rewrite url to /category/pagetitle [duplicate]
- page not found for example.com/custom-post-name
- redirect old post type url to new structure url
- Why won’t this rewrite rule work?
- Parent cpt/child custom post type URL permalink relationship
- Rewriting a custom-post-type permalink with taxonomy term?
- Custom Post Type Permalink / Rewrite not working immediately
- How can I rewrite URLs to pass taxonomy and post type values to the query?
- Custom post type taxonomies URL rewrite
- Permalinks so that one custom post type appears to be a child of another, not working
- Create permalink structure for one taxonomy archive per custom post type
- Custom permalinks
- WordPress Custom Post Type Category Page
- Issues when rewrite rules collide?
- Prepend meta_value to permalink of post
- Custom Permalinks for Custom Post Types and Taxonomies
- Rewrite custom post type url’s adding meta box values
- Multiple parameters in a custom post type url rewrite
- Need help with complex custom post type setup
- Custom post type category, taxonomy and URL rewrite problem
- Custom Post Type/ Taxonomy URL rewrite
- multiple url slug for single custom post type
- Pretty URLs for Custom Post Type & Custom Taxonomy with Duplicate Slugs on WPML
- Custom Post Type and Custom Taxonomy Permalinks
- Pagination problem
- Change Permalink Structure for Tag.php template
- wp_list_categories() – current-cat class also inside posts?
- Custom Post Types, URL rewrite on multiple CPTs
- Adding custom post category slug in permalink causes 404 error for pages and posts
- How can I use get_post_meta with add_rewrite_rule to build custom permalinks?
- How can I make the slug of the taxonomy also the slug of the custom post
- How to rewrite url for any specific taxonomy?
- Custom post URL 404 error
- Remove slug in URL custom post type
- cpt and page sharing same base permalink
- URL rewriting for CTP assigned entity
- Custom taxonomy returns 404
- CPT’s with landing page instead of archive – Url Rewrite?
- Pretty URLs and custom post types
- Specific routing for CPT
- Properly flush rewrite rules on plugin activation
- Best way to specify “article type” in URL
- Custom Rewrite Rule for Custom Post Type with URL Param
- post_type_link Filter – Too Few Arguments
- Add Custom Values to Permalinks Through Custom Fields and Posts
- Archive page for custom post type and custom taxonomy
- Custom taxonomy terms as children of multiple custom post types
- Custom Post Type & Taxonomies – Rewrite
- Remove custom permalink base from CPT custom category and custom tags
- How to handle this wordpress custom post type rewrite problem?
- add_rewrite_rule wordpress ignoring url pattern, wp rewrite not working
- Permalinks: custom post type -> custom taxonomy -> custom sub taxonomy -> post
- Pretty Permalinks with CTP and Taxonomies / Hierarchical
- add_rewrite_tag broke permalinks that doesn’t use that specific tag
- Custom URL for Custom Post Type & Custom Taxonomy Term
- Custom taxanomy and custom post type – pagination leads to 404
- Flush rewrite rules when new cpt is registred
- Custom taxonomy archive slug overwrites static page
- Group based routing and administration
- Adding Custom Taxonomy Along-with Post Name in Post Type Permalink
- I have a custom taxonomy assigned to two post types. How do I create URLs for different term archives for each post type?
- Rewrite Rule & Regex – Extract ‘cat-name’ and ‘page-number’ from http://domain.com/custom-post-type/category/cat-name/page/page-number
- 404 Error On Custom Taxonomy Pages 2, 3, etc
- add_rewrite_rule not working in Custom Post Type UI Plugin
- Url rewrite with custom post type and taxonomy
- Same slug for Custom Taxonomy archive and CPT archive – Rewrite rule not working
- Custom post type with custom taxonomies structure url not working archive of CPT
- What is the best way to relate different custom post types?