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
- Custom post types, taxonomies, and permalinks
- Permalinks: custom post type -> custom taxonomy -> post
- How to rewrite URI of custom post type?
- How do I append multiple taxonomies to the URL?
- 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
- Permalinks when filtering multiple custom post types by single taxonomy
- custom taxonomy archive by year
- Parent & Child Taxonomy slugs in custom post permalink
- Custom Post Types and independent Categories – complex Taxonomy
- Custom Taxonomy URL are redirecting to page with the same name
- 404 Issue w/ Custom Post Type – using Meta for Permalink rewrite
- How can achieve this permalink perfectly? domain.com/%category%/%post-name%
- custom-taxonomy/post_name instead of the default post_type/post_name
- 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/
- Custom Permalink to remove category word , keeping posts permalink with date?
- 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
- How to change permalink to include custom post type
- Template files for Custom Post Type and Taxonomy
- How to have permalink like domain.com/term/postname?
- How to filter a custom post type by custom taxonomy without 404
- Post type Permalink
- How to rewrite the post slug of a custom post type post
- Custom Post Type nest under a normal WordPress Page
- Is it possible to have hierarchical taxonomy and hierarchical custom post types in one permalink?
- Custom category URL not displaying posts
- Use a different URL path / permalink for CPT
- Custom taxonomy terms as children of multiple custom post types
- Duplicate slug/permalink issue while adding same post name
- Remove custom permalink base from CPT custom category and custom tags
- How to handle this wordpress custom post type rewrite problem?
- % encoded URL giving 404 error in WordPress
- Issue with Custom Post Types and Permalinks
- Custom URL for Custom Post Type & Custom Taxonomy Term
- Custom post type URL structure with site.com/custom_taxonomy_slug/post_name
- I have a custom taxonomy assigned to two post types. How do I create URLs for different term archives for each post type?
- How to have permalink structure based on taxonomy terms
- Multiple post types or single post type with category taxonomy?
- How can I add a “fake” parent into the permalink?
- Customizing the custom post type permalink
- Adding 2 CPT with multiple custom taxonomies to permalinks
- Custom Post Type – Rewrite slug [duplicate]
- Permalink for Custom Post Types
- How to change custom post type slug without damage seo? [closed]
- Custom Post Type with multiple Custom Taxonomies / Hide Taxonomy Slug from URL