I fixed my problem as follows:
// Adds rewrite rules for shop post type
function gtp_add_shop_rewrite_rules() {
add_rewrite_rule( '^shop/([^/]*)/([^/]*)/([^/]*)$', 'index.php?shop-category=$matches[1]&width=$matches[2]&height=$matches[3]', 'top' );
add_rewrite_rule( '^shop/([^/]*)/([^/]*)$', 'index.php?shop-category=$matches[1]&width=$matches[2]', 'top' );
add_rewrite_rule( '^shop/([^/]*)$', 'index.php?shop-category=$matches[1]', 'top' );
}
add_action('init', 'gtp_add_shop_rewrite_rules', 10, 0);
Related Posts:
- Difficulty with rewrite rules
- Rewrite rule to prettify two $_GET variables while in a new endpoint from a page
- remove query arg from url after set query
- Add URL Rewrite Rule To WordPress
- WordPress rewrite with custom parameter doesn’t work
- Generate custom output on URL with directory
- Need help with add_rewrite_rule
- Custom post type permalink endpoint
- Search custom taxonomy term by name
- How to stop wordpress to make the default query?
- Adding meta values to permalink
- Permalinks so that one custom post type appears to be a child of another, not working
- Query two taxonomies via URL or link?
- Custom taxonomy on permalink
- How to trigger 404 for custom query var?
- Prepend meta_value to permalink of post
- Using two permalinks for one post
- WP Rewrite Rules – Custom post type & taxonomy
- Remove base slug in CPT & CT, use CT in permalink
- Custom rewrite rules for feeds of custom queries (query_var query strings in URL)?
- Custom page template query_vars
- Rewrite url / permalink for default archive – yearly / monthly
- Is there a PHP function that can match anything after the given URL, so my IF statement will work in each instance?
- Permalinks, Rewrites, Get Variables, Oh My!
- Change permalink for a single post entry
- Custom Permalink Tag breaks Pagination
- Add parent/child taxonomy to custom post type url
- rewrite_rule for custom post type doesn’t affect get_permalink
- Add ‘articles’ prefix before blog posts url without affecting pagination
- custom permalink/shortlink with base62 encoded post ID
- Custom Permalink for Taxonimie and Custom Post Type
- Add specific word to default page permalink
- Multiple instances of Featured Image Query
- When is it a good idea to build a permalink structure from scratch?
- Why doesn’t flush_rewrite_rules run on plugin activation?
- I need a custom permalink for my website
- Permalink Structure CPT With Custom Taxonomy Fails
- Permalinks: Page Not Found
- Why is add_rewrite_endpoint incompatible with /%category%/%postname%/ permalink structure?
- Making a custom help center page
- WordPress custom post type permalink: website.com/post-name/post-id
- Remove custom taxonomy base from URL
- add_rewrite_rule not working for me
- Using WP Rewrite, but just not “getting it”
- Share same Slug for a Custom Post Type and 2 Taxonomies
- How can I use get_post_meta with add_rewrite_rule to build custom permalinks?
- rewrite URL based on selected taxonomy for post page
- How to figure out redirection and contents in hybrid solution containing word press content and legacy code (ASP.net)
- Can’t get custom rewrite tag, query var, permastruct (permalink structure), and rewrite rule to work properly together
- WordPress Persistent connection rule does not work for “posts”
- Customize Custom Post Type URL
- Rewrite CPT permalinks and include WPML language
- Custom Permalinks with CPT and Hierarchical Taxonomies
- Rewrite rule intended for CPTs gives 404 for pages
- How to display an other custom post type in a different custom post type’s archive?
- Permalink structure between 2 custom post types and a taxonomy
- how to change permalinks format for pagination?
- Create custom permalinks to show Custom Post Type’s relationship?
- Permalink structure with custom taxonomies and custom post type like /parent-tax/child-tax/custom-post-type-name (with no base name)
- How to get list of posts from permalinks?
- Rewrite Rules returning wrong data
- Pretty URLs and custom post types
- Permalinks only for posts
- add_rewrite_rule behaving strangely
- Custom rewrite rule ignored
- Pagination for blog posts reloading same page [closed]
- How to change url for taxonomy pages?
- How to use if($wp_query->query_vars[‘name’] == ‘pagethatdontexist’) without getting a 404? How to suppress 404
- Default permalink structure causing Notice: Undefined property: WP_Query::$post
- Set parent for custom post type archive rewrite url
- add_rewrite_rule – Page Slug from “/foo-bar/” to “/foo/bar/”
- WordPress custom permalink and archive link for custom post type
- How can I set up a secondary permalink structure?
- How to Use metada Value in Url and is it possible? [duplicate]
- Safest way to create a custom permalink
- Custom WooCommerce rewrite rules with comma delimiter
- rewrite based slug standar post wp
- Create different permalinks for same post
- remove SLASH on single_post but KEEP on categories and parent pages
- How do I get the correct URL?
- How can I re-query post_type and rewrite the url?
- WordPress Multisite ABSPATH and get_home_path() to check for htaccess or web.config file
- Redirect page to homepage, keeping URL
- Add slug to default post permalinks ONLY
- How to add rewrite rule for product compare page?
- Remove “category” from permalink with add_rewrite_rule
- how to have same rewrite rules for 2 different post type?
- Permalink structure /page/page/cpt-post gives 404 with pagination
- What permastrusture tags are generated out of the box right after creating custom post types and taxonomies?
- Rewrite posts url as they’re all children of a page
- a way to support totally different url structure
- Own query vars are not displayed
- Multiple Permalink Patterns for one page
- Pretty Filter URL
- How to list posts of a given format
- Prevent guessing slug
- WordPress permalink still not working (error or not understood?)
- Custom post type permalink structure
- How to get child pages and add unique class only to active page?
- What is the best way to relate different custom post types?