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
- remove “index.php” from permalinks
- Passing and retrieving query vars in wordpress
- Custom rewrite rules for archive page and single post
- WordPress Rewrite Rules for Custom Post Type and Taxonomy
- Custom post type permalink endpoint
- Multiple post types – share same ReWrite slug?
- Search custom taxonomy term by name
- How to add a custom URL placeholder to author archives?
- How to stop wordpress to make the default query?
- How to modify URL structures in custom post types and taxonomies or terms
- Adding meta values to permalink
- Removing taxonomy base using WP rewrite
- URL Rewrite + Page + Custom Post Type = Unusual Redirect
- Make post slug have priority over category slug
- 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?
- Permalink rewrite with custom post type and custom taxonomy
- Multiple endpoints in one URL
- Prepend meta_value to permalink of post
- Using two permalinks for one post
- flexible rewrite ‘ramble’ URLs with WordPress
- Permalinks for CPT breaks permalinks to pages
- WP Rewrite Rules – Custom post type & taxonomy
- Remove base slug in CPT & CT, use CT in permalink
- Change the custom post type 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
- Can not switch the queried post in pre_get_posts hook
- WordPress Rewrite rule for nested post types
- Is there a PHP function that can match anything after the given URL, so my IF statement will work in each instance?
- Determine WP_Query parameters from URL
- Permalinks, Rewrites, Get Variables, Oh My!
- Change permalink for a single post entry
- Get the post permalink within the loop but without additional DB query
- Get rewrite result
- How to Modify Existing Rewrite Rules?
- 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?
- WordPress not respecting template hierarchy (fetches index.php instead of single.php or page.php)
- Call to a member function add_rule() on a non-object
- Why doesn’t flush_rewrite_rules run on plugin activation?
- I need a custom permalink for my website
- How to set up Author archives with sub category URL
- Permalink Structure CPT With Custom Taxonomy Fails
- Permalinks: Page Not Found
- Why is add_rewrite_endpoint incompatible with /%category%/%postname%/ permalink structure?
- Re-write specific custom post type category URL to go to another page
- Making a custom help center page
- WordPress custom post type permalink: website.com/post-name/post-id
- Remove custom taxonomy base from URL
- remove sub-category of Custom Post Type from permalink structure
- add_rewrite_rule not working for me
- Is a permastruct possible on pages?
- Using WP Rewrite, but just not “getting it”
- Rewrite rule for a query string
- Serve specific “template” page at any URL that ends in its slug
- How to change custom post type permalink structure
- Custom permalinks with hierarchical taxonomy – getting PHP warning
- 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
- How can achieve this permalink perfectly? domain.com/%category%/%post-name%
- How to remove specific category from URL in WordPress
- Changes in permalink structure in WordPress and how to apply to in-site links
- 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
- Custom permalink leads to index page
- 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
- Pre-Populate $wp_query settings with custom rewrite rules and custom template_redirect
- Permalinks only for posts
- WP_Query Attachment adds additional attachment count and need to link attachment to post url