You should add your own custom query variable first:
function add_search_store_query_var($vars) {
$vars[] = 'search_store';
return $vars;
}
add_filter( 'query_vars', 'add_search_store_query_var');
And then add rewrite rule:
function add_search_store_rewrite_rule() {
add_rewrite_rule('stores/([^/]+)$', 'index.php?page_id=<YOUR SEARCH PAGE ID>&search_store=$matches[1]', 'top');
}
add_action('init', 'add_search_store_rewrite_rule');
You can then use get_query_var('search_store');
to get search term.
Just remember to flush rewrite rules, before you check it – it won’t work without flushing rules. (Just go to permalink settings and click save).
PS. Coded it directly in here, so it can be a little bit buggy.
Related Posts:
- Force wordpress to display page with same url structure as categories
- remove “index.php” from permalinks
- How to get pretty URLs with add_query_arg in permalinks
- Creating custom permalink structure for languages
- How to remove dates from existing permalinks?
- Getting the Site URL Including the Front Base
- Multiple post categories – single permalink
- Update URL Snippet to Canonical Permalink URL
- “.#[random-char-string]” being inserted at end of URLs
- URL Rewrite + Page + Custom Post Type = Unusual Redirect
- 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
- 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
- Redirecting “wrong” but working links to their canonical URL in order to prevent search engine penalties (e.g. /123/ at the end of URLs)
- 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
- Permalink not changing according to post type
- Using a template file for a specific custom URL
- Extra url paths as variable
- 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?
- Pretty permalinks for search results with extra query var
- Using $_GET variables in the URL?
- Including category-base in a post permalink results in 404
- Filtering categories in the permalink structure
- How do I turn off 301 redirecting posts (not canonical)?
- 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/
- Exclude subcategories from the url
- Rewrite user profile URL to be human friendly
- 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
- Call to a member function add_rule() on a non-object
- 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”
- How to bulk edit image url in featured image and product description?
- Rewrite CPT permalinks and include WPML language
- How to include sub directory in sitemap? [closed]
- Create custom permalinks to show Custom Post Type’s relationship?
- IIS 7 Rewrite with parent categories
- Do WordPress Permalinks Refer to a Lookup Table in the Database?
- Permalinks only for posts
- Permalinks settings
- Changing permalinks structure without loosing SEO
- Visiting posts results in 404 errors after host migration
- Suddenly new posts have the default permalink instead of the post name
- Two URLs of one post is available
- Custom permalink structure with %postname% in front of domain name
- How can I set up a secondary permalink structure?
- How to Use metada Value in Url and is it possible? [duplicate]
- How do I rewrite attachment urls when permalink structure contains %category%?
- Custom child page permalink
- WordPress Primary Category Changes After Import, Permalink Issue
- Safest way to create a custom permalink
- How do I structure my permalinks in WordPress?
- Creating an alternate path for a page
- dynamic URL rewrite
- How to change URL from /%postname%/ to custom-name/%category%/%year%/%monthnum%/%day%/%postname%/
- 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
- Redirect page to homepage, keeping URL
- Adding query string to multiple page urls in a WordPress function
- Updates all internal links on permalink update
- 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
- Search and replace post URL’s on page output?
- Two urls for one website
- WordPress permalink still not working (error or not understood?)
- how to create several url aliases for a page