Solved it!
// Register the variables that will be used as parameters on the url
function add_my_var($public_query_vars) {
$public_query_vars[] = 'extra_slug';
return $public_query_vars;
}
add_filter('query_vars', 'add_my_var');
// Build the rewrite rules, for the extra parameter
function do_rewrite() {
add_rewrite_rule('(accommodation)/[/]?([^/]*)$', 'index.php?pagename=accommodation&extra_slug=$matches[2]','top');
}
add_action('init', 'do_rewrite');
// The parameter is now accessible
get_query_var('extra_slug')
Related Posts:
- Test site pages go to main site
- 301 Redirects for Changed Permalink Structure & Category Base
- How do I turn off 301 redirecting posts (not canonical)?
- Subdomains to pages
- htaccess or redirect to cloak portion of a link?
- Auto 301 to full post permalink? (using /posts/%post_id%/%postname%)
- Using WP rather than .htaccess to redirect pages/posts
- .htaccess – Redirect duplicated post ended in ‘-number/’ to the same url without the -number/
- WordPress redirection problem after moving to a new server?
- Specific URL Rewriting with parameters in wordpress
- If I change permalink structures, can I use htaccess to permanantly redirect links?
- Redirect parent taxonomy to it’s child
- Need Help Correct Regular Expression Redirect Code
- Custom Permalink
- Redirect a Blogger Page URL to wordpress
- Redirecting all posts after changing URL structure with htaccess
- Redirect all posts permalinks from “.html” to “/”
- WordPress 4.4 old permalink redirect
- Htaccess https 301 problem
- Passing the JQuery string to Worldpress URL
- How to use different domains for different blogs hosted in the same host in subdomains with .htaccess
- What causes /pages/ to appear in URI, and how to remove it?
- Some Pemalink problems, probably caused by wrong .htaccess configuration?
- Comment author url link is wrong? How to change from authors/ to author/
- Redirect From Url To Url
- change WordPress permalinks and redirect new urls 301
- Custom permalink structure with %postname% in front of domain name
- Configuring Home Page Address
- WordPress Page Not Found if Permalink Settings is Postname
- Can’t access WordPress site in subfolder possibly because of .htaccess redirect from root installation?
- Removed and Reinstalled WordPress, Redirect Broken now
- redirect old pages by .htaccess
- Why are all pages redirecting to homepage when using custom permalinks?
- .htaccess regex for redirect subdomain to root domain & redirect old permalinks
- 404 posts error after 301 redirection of changed category / tag base
- 301 Redirect posts to newly added categories
- Does WordPress Change the .htaccess File When Updating?
- Removing the redirect after changing a page’s slug
- Page begins with number, WordPress adds 2
- Permalinks to Custom does not work (out of box)
- URL rewrite based on a custom field value
- Redirect old permalinks to new permalinks
- Permalink Issues by Installing WordPress in Subdirectory / Subfolder
- How can I include a query string with get_permalink
- How to map permalinks with accented letters to sanitized slugs?
- WordPress overrides the GET variables, (page_id) set in HTACCESS
- Changing URL from /%postname%/%post_id to /%category%/%postname%/%post_id%
- How to change the permalink structure of a master page?
- Rewrite rule never matching
- WordPress 3.4 Permalinks Redirection Problem
- Custom url for a single page
- Rewrite-Rules not working on a vhost, everything goes to index.php
- Does WordPress send a 301 header message when you change permalink structures?
- WP Site in subdirectory Joomla! Site – Permalinks not working
- Redirect Loop to Page, Can’t Find Origin, Can’t Remove [closed]
- 404 with post name permalinks
- How to protect htaccess so it can’t be overwritten?
- Permalinks not working
- Infinite redirects after changing the permalink of a page
- Permalinks settings page blank
- 301 Redirects Result in 404 for WordPress Search Query Strings
- After updating to 4.8 permalinks will not work (all 404)
- How to get post object on blog template
- WordPress Sub domain
- Redirect /%year%/%monthnum%/%day%/%postname% [closed]
- URL rewriting: removing the site’s basename for a specific category
- get_permalink returning site home url instead of the url of slug being passed
- Host frontpage via example.com and everything else via example.com/blog
- how to redirect old blog post urls when permalinks are changed
- Allow Permalinks to Work with and without Hyphens
- Resolve 404 on posts without category
- How do I reclaim either deleted pages or their permalinks?
- url rewrite .htaccess extension to permalink
- Permalink of a page that has already been deleted
- “-2” Being added to end of URL (no duplicate pages, no pages in trash)
- Folder wordpress page redirect
- How to rewrite a page url
- Get a link to paged() part?
- How Can I Use a Custom AccessFileName?
- xammp server permalink by postname not working
- Redirect after permalink changes
- Custom permalink structure only saves with index.php inserted
- Blogger To WordPress Permalink Redirection
- Permalinks and page store
- How can i fix my permalinks?
- remove SLASH on single_post but KEEP on categories and parent pages
- Link to a page before launch
- .htaccess to redirect to a wp page
- My WP homepage works, but the other pages don’t when accessing from out side of my network
- Got 404 error when changed siteurl via DB in WordPress
- All files in public_html, Cannot launch WordPress site via wp-admin
- Woocommerce product page 404 not found
- Page permalink redirects to home page
- Removing or hiding slug/permalink from htaccess
- How to hide slug numbers with htaccess
- Allow arbitrary text after page URL
- When using number in url it is redircting to same page but when using character it redirects to 404
- Once redirected by Rewrite rules, how can WordPress know the page?
- Redirect Pretty Permalinks to Ugly Permalinks
- My wordpress site must be being affected by outside sources [duplicate]