I had the same technical need as you, and I have did this(code below) to get it work :
function my_custom_rewrite_tag() {
add_rewrite_tag('%xxx%', '([^&]+)'); //change the regex to your needs
add_rewrite_tag('%yyy%', '([^&]+)'); //change the regex to your needs
}
add_action('init', 'my_custom_rewrite_tag', 10, 0);
function my_custom_rewrite_rule() {
add_rewrite_rule('^tour/([^/]*)/([^/]*)/?','index.php?pagename=tour&xxx=$matches[1]&yyy=$matches[2]','top');
}
add_action('init', 'my_custom_rewrite_rule', 10, 0);
Finally, do not forget to flash the permalinks structure from your dashboard.
Related Posts:
- Custom Post Type Permalink / Rewrite not working immediately
- How to remove /blog/ prefix for custom post types in permalinks?
- Custom Post Type Permalink Page Not Found
- WordPress Custom Post Type is Matching on Partial Slug
- Changing the URL Structure of a Paginated Custom Post
- Change slug of registered custom post type in child theme
- Templates for Custom Post Types and Custom Taxonomies
- Permalinks so that one custom post type appears to be a child of another, not working
- Create permalink structure for one taxonomy archive per custom post type
- Custom permalinks
- Permalink for CPT with taxonomy
- Understanding Permalinks on Custom Post Types
- Custom post type permalink changing itself every other change
- Add links to post categories and taxonomies in wysiwyg link modal?
- Custom Permalinks for Custom Post Types and Taxonomies
- Removing parent slug from URL on custom post type
- Maintaining WP_Query Relation Among CPT, Custom Taxonomy, Permalinks- CPT UI
- Custom post type category, taxonomy and URL rewrite problem
- Define permalinks for custom post type by taxonomy in WP 3.4
- Rewrite on custom post type permalink not working?
- Custom Post Type: How to display all of same taxonomy?
- Custom post type permalink missing /post_type/ front
- Remove POST_TYPE from custom post type permalink
- Remove “-2” from a Toolset Types URL with the same post name
- Custom post types and permalink
- Permalinks for Taxonomy and Custom Post Type
- custom post type default permalink
- Programmatically adding posts
- multiple url slug for single custom post type
- Custom post types, taxonomies, and permalinks
- How to specify URLS for custom posts & taxonomies
- How do I fix permalinks for custom post types that has the same slug as a page?
- Permalinks not working for custom taxonomy on custom post type
- Why does wordpress keep adding postname to my CPT’s permalink in the end?
- Custom Post Type permalink shows wrong page: homepage/index.php
- Get term name and term parent into custom post type permalink
- Rewrite rules for custom posts types
- Does WordPress consider a post name unique if that same post name is in multiple Post Types?
- Custom post type url with category
- Custom post type as home page with custom url
- URL rewrite add author as base
- Custom Post Type Permalink empty
- Parent Page and Breadcrumb URL’s for Custom Post Types Not Working
- CPT’s with landing page instead of archive – Url Rewrite?
- Custom post type and taxonomy permalinks
- Hierarchical permalinks for custom post type and taxonomy
- How to organize hierarchical structure in custom post type with taxonomy (like with categories)
- Form action doesn’t work if slug isn’t same as custom post title
- Custom Post Type – Duplicate Page Slugs
- Remove permalink for custom post type
- Best way to specify “article type” in URL
- Template files for Custom Post Type and Taxonomy
- How to have permalink like domain.com/term/postname?
- Custom post type permalink returns 404 when set to private
- Custom post type slug 404
- Post type Permalink
- get the permalink never return with empty value
- Redirect User From Registration Page To CPT (profile page) with custom url
- Custom Post Type with Configurable Sidebar via ACF
- Setting a homepage – doesn’t seem to work
- Improve Custom Post Permalink Structure
- Using page title as a link to term archive
- Pagination does not work on Custom Post Type archive while trying to get load more function working
- Custom post type permalink structure to include the taxonomy
- Custom Post Type permalink doesn’t match post permalink
- I want to rewrite the URL of a specific post with a specific custom field to easily analyze in Google Analytics
- How to mass get post editor URLs
- Error 404 change permalink term custom term taxonomy
- WordPress URL rewrites using Advanced Custom Field
- Preview url not working outside wp-admin
- Permalink for specific post type
- Custom post type defaults to index.php for archive page
- Permalink for custom post type pages not working
- Adding categories to custom post type in permalink
- Change custom post type permalink according to category
- Pretty permalink structure with multiple (AND OR) taxonomies
- 404 custom post type
- Custom post URLs
- Is it possible to have public posts in a non-public custom post type?
- How can I add a “fake” parent into the permalink?
- Custom Post Type Archive Links Not Working
- Custom Post Type Categories Not Maintaining URL structure any more
- Add category slug as class attribute in a link array
- Custom post type child page 404
- Get post id of permalink for a specific custom post type?
- URL Rewrite Adjustment for Custom Post Type causes template to revert to index.php
- WordPress Custom Permalink Structure with Custom Post Type and Taxonomies
- Add taxonomy to custom post type archive
- Can’t preview custom post – Redirected to home page
- Custom Post Type – Rewrite slug [duplicate]
- Custom Post Type Permalinks with %category%
- Custom post type – permalink
- Custom post types permalinks not working
- Rewrite rules for using the same base slug for multiple content types
- Problem with Custom Post Types, Taxonomy, permalink, Archive
- PHP Button Custom link [closed]
- Custom post type, when type non existing post name, it query the nearest possible post name by default. How can I disabled this behavior
- 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