I find a solution thank you to the plugin:
Monkeyman Rewrite Rule
With this plugin I find when the rule failed, then I corrected it with these lines of code:
add_action( 'init', 'ab_category_rewrite_rules' );
function ab_category_rewrite_rules() {
add_rewrite_tag( '%category%', '([^/]+)', 'category=' );
add_permastruct( 'category', '/catalogs/%catalog%/%category%', false );
add_rewrite_rule( '^category/([^/]+)/([^/]+)/?$', 'index.php?category=$matches[2]', 'top' );
}
add_action( 'init', 'ab_product_rewrite_rules' );
function ab_product_rewrite_rules() {
add_rewrite_tag( '%product%', '([^/]+)', 'product=" );
add_permastruct( "product', '/catalogs/%catalog%/%category%/%product%', false );
add_rewrite_rule( '^product/([^/]+)/([^/]+)/?$', 'index.php?product=$matches[2]', 'top' );
}
I also removed the rewrite
option config on my custom post type registration function (for category and product type).
Related Posts:
- Custom Post Type URL Rewriting?
- Add .html (dot HTML) extension to custom post types
- Multiple post types – share same ReWrite slug?
- How to pass URL parameters for advanced taxonomy queries with multiple terms for one custom taxonomy
- Custom post types – Use post_id in permalink structure when using has_archive => true
- Slug for custom post type archive
- Change page /2 to /transcript with a Rewrite
- Permalink rewrite with custom post type and custom taxonomy
- Make permalinks based on an ACF-field
- How would I leverage custom Taxonomies in this scenario?
- WordPress returns 404 on custom rewrite rule conflict in parameters
- How to create download links based on Custom Fields with Rewrite API
- How to rewrite custom post type URL for multiple depths instead of one specific depth
- Regex problem in an add_rewrite_rule
- Multiple Permalinks for custom post type post
- Interesting Custom Post Type Slug with Taxonomy and Custom Field
- WordPress Rewrite rule for nested post types
- Category base to url in custom post type/taxonomy
- Is slug “type” reserved and can’t be used in taxonomy rewrite?
- Custom Post Type get_post_type_archive_link( $post_type ) returns false
- Permalinks when filtering multiple custom post types by single taxonomy
- custom taxonomy archive by year
- How to Combine Two Custom Post Types into Single Permalink Structure
- Redirecting when changing custom post type slugs?
- How can you handle rewrite rules for custom post types with option to filter on custom taxonomy terms?
- Conditional regex in add_rewrite_rule() for specific query filters & pagination
- How to remove slugs from multiple custom post types
- Displaying Posts of a Custom Type
- Can’t change first part of URL rewrite for custom post type
- CPT Archive with core Category
- Custom taxonomy in URL showing 404
- Relative URLs for a particular custom post type?
- Custom Taxonomy URL are redirecting to page with the same name
- Rewrite slug of custom post type to include post-id
- How can we take into account post types when constructing permalinks?
- Taxonomy custom post type URL
- How to change custom post type permalink structure
- Front custom edit post page for each post
- Categories of Custom Post throws gives 404
- How to build custom route by adding taxonomies to URL ? ex: www.demo.com/communities/palo-alto/
- 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
- Rewrite Question Mark in Post Template to Make it Pretty URL
- How can achieve this permalink perfectly? domain.com/%category%/%post-name%
- Custom Permalink to remove category word , keeping posts permalink with date?
- WP Rewrite Rule Issue while using Custom post type & taxonomy
- WordPress custom post type split into pages
- WordPress uses url different from defined in rewrite arg of custom post type
- Including taxonomy term before post type breaks top level pages
- Correct procedure for advanced permalinks
- Custom Post Types hierarchy and rewrite
- How to get list of taxonomy slugs ordered parents>childs?
- Rewrite rule for Custom Post Type Page as a parent
- Rewrite Endpoints and CPTs – How to use in a plugin
- add_rewrite_rule and passing variables for custom post types
- Custom post type’s permalink adds the name of the post type before the post name
- Custom taxonomy and post type with same slug
- Permalink misbehaving in Custom Post Types
- I can’t access custom taxonomy page listing
- Combine multiple CPT names to create valid permalinks
- Add term slug in URL of custom post type details page
- Programmatically add custom field to post_name in a custom post type
- How to rewrite custom taxonomy term archive to use THE SAME SLUG/front as CPT
- How to create custom search result page with custom URL parameters for custom post type?
- Page inside custom post type (url rewrite?)
- Rewrite permalink for multiple post types (CPT) with taxonomy term
- How to constrain the results to a specific post_type on tag archive page?
- rewriterule not working
- Modifying rewrite rules to use /category//
- Custom Post Type View Button in Admin Gives 400 Error
- Custom Post Type URL Rewrite’s
- Custom Post Type Date Based Archive URL rewrite [duplicate]
- restricting custom rewrite to just one custom post type
- returning the currect URL for nested posts
- 404 error rewrite permalinks
- Rewrite URL for CPT to domain/post-name/post-id
- Custom rewrite rule based on other custom post type title
- How to apply multiple rewrite_rule to a single custom post type url?
- Custom permalink structure for custom post types including multiple taxonomy
- How can I assign multiple parents to CPT?
- CPTs relationship
- Add %post_id% to slug of custom post type and prevent the “unique slug” thing that WP does?
- Rewrite url for custom post type with specific url
- Customise Permalink Structure For Custom Post Types
- How to make “single post” permalink maintain it’s sub-page structure
- Custom Post Type canonical link / pagination redirecting to root
- Rewrite url post_tag for custom post type
- How to build overlapping custom post_type and taxonomy rewrites without conflicts?
- Two CPT: one is using part of the custom rewrite slug from the other
- WordPress custom post type rewrite rule matches all pages returning 404
- Rewrite Endpoint Url without ? before endpoint
- How Can a CPT in WordPress have a page 2 without an error?
- current_menu_parent for custom post type and custom url
- Remove sequential number from permalinks
- Parent cpt/child custom post type URL permalink relationship
- Custom post type and custom taxonomy archive inaccessible
- Rewrite Rule for custom post type link with or without taxonomy terms
- Custom post type Premalinks main page and details page
- Rewrite rule taxonomy url with different values in one function
- Custom URLs between different post types, using “Pods”