The correct way to register the rewrite rule and rewrite tag for your case is:
function custom_rewrite_rules() {
add_rewrite_tag('%nights%', '([^&]+)');
add_rewrite_tag('%people%', '([^&]+)');
add_rewrite_rule('house/(.+)/(.+)/(.+)/?$', 'index.php?house=$matches[1]&nights=$matches[2]&people=$matches[3]', 'top');
}
add_action('init', 'custom_rewrite_tag', 10, 0);
The code has been tested and works correctly.
Related Posts:
- remove “index.php” from permalinks
- How to get pretty URLs with add_query_arg in permalinks
- Creating custom permalink structure for languages
- Getting the Site URL Including the Front Base
- Update URL Snippet to Canonical Permalink URL
- “.#[random-char-string]” being inserted at end of URLs
- URL Rewrite + Page + Custom Post Type = Unusual Redirect
- Pretty Permalinks
- How to create a permalink structure for posts in a specific category
- Remove subfolders from URL
- flexible rewrite ‘ramble’ URLs with WordPress
- Custom rewrite rules for feeds of custom queries (query_var query strings in URL)?
- How to Modify Existing Rewrite Rules?
- custom permalink/shortlink with base62 encoded post ID
- How to reset canonical URLs / fix redirect loop
- Change blog segment of URL
- Force wordpress to display page with same url structure as categories
- How can i have a custom post type with more slugs for each post?
- URL rewriting: removing the site’s basename for a specific category
- mod-rewrite exception? keep #hash in matching urls?
- Remove parent page from url
- Getting back a permalink from custom url
- Bulk append URL (add word to slug)
- Access posts while mod_rewrite is broken
- Can I change the URL structure for a CPT only?
- Multiple Taxonomy Items for Separate URLs
- WordPress keeps removing query var from the URL
- How to construct a dynamic rewrite rule for child pages that passes more than one query var
- Using a template file for a specific custom URL
- Passing parameter through permalink structure
- rebuilding/ rewriting a url to make it SEO friendly
- a way to support totally different url structure
- How to change URL of my pages?
- Custom Permalink Base
- Include language variable in url
- How to get the perfect WordPress, WooCommerce, Custom Post Type pretty permalinks?
- Including category-base in a post permalink results in 404
- WordPress thinks my custom route is a 404
- How to prevent apostrophes and quotes from appearing in permalinks?
- Remove parent slug for child pages
- Limiting the number of words or characters in the slug/permalink
- How can I Rewrite a ‘page’ URL based on query string parameters?
- custom naming of search permalink /search/
- Using WP rather than .htaccess to redirect pages/posts
- How can I get the permalink of a post before it is published?
- Add a URL prefix to permalinks of News category and sub-categories of posts only
- add new permalink structure from dynamic page
- echo post-permalink without http and www
- Custom taxonomy rewrite using tax name instead of rewrite slug
- Why is add_rewrite_endpoint incompatible with /%category%/%postname%/ permalink structure?
- Custom permalink for search and pagination
- add_rewrite_rule not working for me
- Using WP Rewrite, but just not “getting it”
- Rewrite CPT permalinks and include WPML language
- How to include sub directory in sitemap? [closed]
- Do WordPress Permalinks Refer to a Lookup Table in the Database?
- 404 error using Meta for Permalink rewrite
- Permalinks settings
- How to handle paging/pagination with a custom permalink?
- Visiting posts results in 404 errors after host migration
- Problem with parent page slug only in WordPress admin
- Custom URL rewrites for templates
- “-2” Being added to end of URL (no duplicate pages, no pages in trash)
- Redirecting “wrong” but working links to their canonical URL in order to prevent search engine penalties (e.g. /123/ at the end of URLs)
- How to change custom post type, blog post and page permalink by template?
- Change permalinks for specific pages
- How can I set up a secondary permalink structure?
- How to get raw unwritten querystring
- How do I rewrite attachment urls when permalink structure contains %category%?
- Post with no tag permalink problem
- How do I structure my permalinks in WordPress?
- Creating an alternate path for a page
- I want to rewrite the URL of a specific post with a specific custom field to easily analyze in Google Analytics
- How to change URL from /%postname%/ to custom-name/%category%/%year%/%monthnum%/%day%/%postname%/
- Adding a ‘blogs’ prefix in the URL structure but only for blogs
- WordPress Attachment Page URL Rewrite!
- Customize URL for specific tags archive
- Add #primary at the end of navlink permalinks on single posts
- WordPress Multisite ABSPATH and get_home_path() to check for htaccess or web.config file
- Flushing rewrite rules enables to see an article, but I didnt change anything
- Redirect page to homepage, keeping URL
- Adding query string to multiple page urls in a WordPress function
- I have Akamai pointing to a WordPress installation with a different URL. Is there a way to make WordPress use this for link generation?
- Updates all internal links on permalink update
- 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
- Multiple Permalink Patterns for one page
- Issues with WordPress permalinks
- WordPress permalink still not working (error or not understood?)
- Update permalinks after domain change
- How to shorten the Permalink after WP>WP blog import?
- how to create several url aliases for a page
- Single product link in woocomerce
- URL issues with WordPress
- Add additional URL variations for a Post
- Remove parent product category slug from product_cat url woocommerce
- How to make my custom permalink pull up the correct post
- Can’t Remove Unnecessary Slug