After testing countless different structures i came up with this. It’s manual work specifying each category but gives me more control.
If someone comes up with a better solution, please let me know.
function mmp_rewrite_rules($rules) {
//Product structure
$newRules['product/(.+)/(.+)/(.+)/(.+)/?$'] = 'index.php?products=$matches[4]';
//The above structure only works of the postname is the 5th uri segment
//It's more flexible to confugure the depths for each category below
$newRules['product/televisies/(.+)/(.+)/(.+)/?$'] = 'index.php?products=$matches[3]';
$newRules['product/sports/(.+)/?$'] = 'index.php?products=$matches[1]';
//Category rule
$newRules['product/(.+)/?$'] = 'index.php?pcategory=$matches[1]';
return array_merge($newRules, $rules);
}
Related Posts:
- Mixing custom post type and taxonomy rewrite structures?
- Rewriting a custom-post-type permalink with taxonomy term?
- WordPress Rewrite Rules for Custom Post Type and Taxonomy
- How to modify URL structures in custom post types and taxonomies or terms
- Create permalink structure for one taxonomy archive per custom post type
- Custom permalinks
- Permalink rewrite with custom post type and custom taxonomy
- Custom Permalinks for Custom Post Types and Taxonomies
- Including two taxonomies in a permalink structure
- WP Rewrite Rules – Custom post type & taxonomy
- Remove base slug in CPT & CT, use CT in permalink
- Custom post type category, taxonomy and URL rewrite problem
- Permalink Structure problem with cpt and custom taxonomy
- Custom Permalink Tag breaks Pagination
- Custom Permalink for Taxonimie and Custom Post Type
- multiple url slug for single custom post type
- Custom Post Type and Custom Taxonomy Permalinks
- Permalink Structure CPT With Custom Taxonomy Fails
- Change Permalink Structure for Tag.php template
- Custom taxonomy in URL showing 404
- Adding custom post category slug in permalink causes 404 error for pages and posts
- How Can I Change the Custom Post Type Slug to the Taxonomy Slug in the URL?
- Use same slug base for Custom Post Type posts, and multiple taxonomy terms
- How to create custom url structure based on custom post type rewrite slug, taxonomy and category slug?
- Customize Custom Post Type URL
- Custom Permalinks with CPT and Hierarchical Taxonomies
- Custom Permalink Structure for Custom Post Type, Custom Taxonomy, Under a page
- Custom taxonomy returns 404
- CPT’s with landing page instead of archive – Url Rewrite?
- Permalink structure with custom taxonomies and custom post type like /parent-tax/child-tax/custom-post-type-name (with no base name)
- Custom permalink with child taxonomy terms
- Best way to specify “article type” in URL
- Custom Post Type Advanced Slug
- WordPress custom permalink and archive link for custom post type
- Custom Permalink For Custom Post Type – Working Fine But Broken For Pagination
- Permalinks: custom post type -> custom taxonomy -> custom sub taxonomy -> post
- Pretty Permalinks with CTP and Taxonomies / Hierarchical
- Customise Permalink Structure For Custom Post Types
- Parent cpt/child custom post type URL permalink relationship
- Permalinks: custom post type -> custom taxonomy -> post
- How to rewrite URI of custom post type?
- Custom post types – Use post_id in permalink structure
- Custom Post Type and Taxonomy URL rewrite
- Custom post type permalink: only use %post_id% and remove %postname%
- Permalink rewrite 404 conflict- WordPress Taxonomies/ CPT
- Rewrite custom post type rss feed links
- Archive page with multiple taxonomies rewrite
- rewrite get parameter with custom post type
- Remove unwanted part of permalink custom structure from CPT url?
- Custom permalinks – post type – hierarchical taxonomy’s
- Changing a custom post type “has_archive” after registered
- Page to display an archive of taxonomies
- How to create a permalink for custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
- How to show custom taxonomy in the permalink?
- Date-based permalinks for Custom Post Type, and custom taxonomy permalinks
- Permalinks for custom post-types within custom taxonomies not found
- Parent & Child Taxonomy slugs in custom post permalink
- Custom Post Types and independent Categories – complex Taxonomy
- 404 Issue w/ Custom Post Type – using Meta for Permalink rewrite
- How to add rewrite rule to custom post type with parent in url with cpt ui?
- How do I change the custom taxonomy slug to be the same as the custom post type slug?
- Permalinks /country/city/cpt/postname/
- Seamless permalinks between Custom Taxonomy and Custom Posts
- Custom post type and custom taxonomy with the same slug using the file page taxonomy only as directory
- WordPress uses url different from defined in rewrite arg of custom post type
- How to change permalink to include custom post type
- set permalink for CPT
- Custom URLs in post types make it impossible to view archive
- Permalink problems with custom post type and custom taxonomy
- Route subpage to Custom Post Type
- Add term slug in URL of custom post type details page
- Ideas on how to organize a project [closed]
- Custom post type category permalinks and archive pages
- Adding /blog in front of single posts (only)
- Is there a way to use ‘publicly_queryable’ => false only on specific taxonomy term?
- Define multiple prefixes for custom post type
- Changing permalink of default Post with custom post
- Custom Taxonomy Archive generates 404
- How to create a permalink structure with custom taxonomies and custom post types
- Pagination not working (page/2 retunring 404 page)
- Template hierarchy changes when custom post-type permalink leverages custom taxonomy
- Associate custom CPT with another CPT’s taxonomy and rewrite permalinks
- Post Custom & Taxonomy 404 error
- Remove custom post type slug but keep related category taxonomy permalink
- page not found for example.com/custom-post-name
- Force WordPress to only match URL in category
- Same permalink structure for all post types?
- How to add base permalink to custom posts?
- Custom post type with parent page? Possible?
- Hierarchical taxonomy in permalink structure
- Why won’t this rewrite rule work?
- Category / Custom Post Type permalink issue
- Adding rewrite rules to Custom Post-type mixed with Taxonomy
- Custom post type permalink structure
- How to have a dynamic slug and rendering the archive-{post_type}.php?
- Add /blog to the “post” post type url
- How can i change url structure of cpt like this?
- What is the best way to relate different custom post types?
- Modify permalink of CPT archive to support two taxonomies
- Allow child pages with the same base as the CPT slug