Create a Page Template
Add a new page and give it the slug stores
Add A Public Query Variable
add_filter('query_vars', 'add_state_var', 0, 1);
function add_state_var($vars){
$vars[] = 'state';
return $vars;
}
Add a rewrite rule
This will direct your request to your stores
page.
add_rewrite_rule('^stores/([^/]*)/?','index.php?post_type=page&name=stores&state=$matches[1]','top');
Within your Template
You can access your state variable as follows:
$state = get_query_var('state');
Flush your Permalinks
Visit Settings->Permalinks to flush your permalinks and add your rewrite rule to the stack.
Related Posts:
- Display posts with author in the url with custom post types
- custom htaccess rewrite rule for page
- Adding special characters to slug?
- Preserve old website URL structure after migrating to WordPress
- How to change the Author Slug from Username to Nickname and deal with Special Characters
- Make the home page’s slug visible in the browser’s URL bar
- WordPress is adding “category” word before my actual category name in url (and this is unsolicited)
- taxonomy term in URL slug won’t forward to the correct term for custom post like it does for default categories/normal posts
- Remove Page Slug from URL
- Does WordPress keep track of a post’s URL history and provide automatic redirects?
- Override default url for author pages?
- Change author base slug for different roles
- Custom slug in front of search URL
- Clash of the rewrites
- How to seamlessly redirect between different archive and singular slugs?
- How to prevent redirection to max 2147483647 for larger values of the page query variable?
- How to change default page slug?
- Will references to ugly links automatically redirect to their pretty url permalink?
- how to add prefix to post url structor only
- Why does wordpress still strip my query var?
- Appending numbers to url do not break the link
- Hijacking the URL for filtering
- WP Login forms action URLs displayed as pretty URLs in browser (ex with Restore Password)
- How to change ?lang=cn into /cn/
- How to change page URLs to “www.site.com/page” instead of “example.com/blog/page” but keep post URLs as “example.com/blog/post”?
- Add_query_arg + two times the same argument?
- WordPress 404 unless there is a space in url
- Change default URL of image attachment
- Change WordPress comments url / word
- Migrating a page to be an article
- How to get “extended” path info from URL in a plugin
- Multiple Permalinks for Same Post
- Adding more pages to author pages
- How to check current URL for endpoint in a template file?
- How to perform a query at the URL?
- add_rewrite_rule not working for language specific characters
- Is there a way to create alias without using htacess, permalinks or delving into code?
- Load a template page based on part of slug in wordpress
- Define orderby in url
- Alias ‘wp-content’ directory to something shorter (framework?)
- WordPress .htaccess – route other URLs to another app
- open all .docs in word online
- How to add custom variable in url without redirect?
- Adding pretty query parameters
- Changing RSS feed URL structure
- How to change the main site url on a multisite installation (network)?
- add_rewrite_rule fro html to another url not working
- Preserve Domain Alias
- WordPress redirects non-existing url to existing ones – how to disable
- How to rewrite url wordpress?
- How to building pretty URLs to reflect category hierarchy?
- Wildcard forward all posts and pages with few exceptions
- Help with Rewrite Rule for Custom Post Type with Query String
- Rewrite URLs – Custom Post Type – Post Slug, Taxonamy Slug
- A clean custom rewrite rule for weekly archives
- I want to add a new tag to WordPress URL permastruct
- Add language prefix to permalinks
- How to redirect large amount of URLs?
- Per Page Permalink Structure for Page Post Type
- ngnix Url rewrite doesn’t work
- Understanding the query string after .htaccess rewrite
- URL renaming issue
- Removing “www” from a site URL
- Adding a query string to only one page url
- wordpress url correction
- How do I add a tag slug to a category URL to filter posts?
- Bulk append URL (add word to slug)
- Using URL rewrite to add custom URL for custom post type
- Weird characters behind every single link and images
- Can’t use a specific custom URL (slug)?
- How do I get posts to appear at mydomain.com/blog?
- get variable from url?
- How to transform multiple parameter URL to clean URL
- Changing the wordpress default search url to something like – …example.com/search?query=keyword
- A different permalink structure for different categories
- How to add dot(“.”) in post slug
- How to change search page url so that it still returns a page when there’s no search query specified?
- SEF add_rewrite_rule & add_rewrite_tag not working
- Allowing multiple URLs for same Post
- How to create dynamic URLs on WordPress?
- Problem building an url with argument
- Multiple permalink with and without category for same post
- Add %post_id% to slug of custom post type and prevent the “unique slug” thing that WP does?
- How do I rewrite URL that has custom parameter
- Param causing 404
- Post & Page with same slug
- How to add 2 variable rewrite rule?
- Get custom posts by segment of the URL
- Use Parent Pages for URL Structure without Landing Page
- How to retrive previous Domain URL in Wp
- Needed to change slug to access page
- How to create short urls for sharing and downloadable content?
- URL Rewrite for CPT single posts
- How to stop WordPress creating URLs that don’t exist
- Rename page URL
- Can I exclude a single URL from a rewrite plugin?
- How can i maintain permalink structure and avoid a 404 error when loading external content?
- Remove url parameter using wordpress
- Change the slug ( url ) to a sequence number starting from 0 in the custom record type?
- Custom Post Type with multiple Custom Taxonomies / Hide Taxonomy Slug from URL