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?
- Need help with add_rewrite_rule
- Stop WordPress appending `-2` to the end of my url after i change it
- Permalink format: singular or plural
- Get current URL (permalink) without /page/{pagenum}/
- How to change author base without front
- How to map permalinks with accented letters to sanitized slugs?
- Add custom directory in URL
- Using two permalinks for one post
- Custom rewrite rules for a $_GET request
- How to increase the character limit for post name of 200?
- Put post ID on the custom post type URL
- How to allow slashes in single posts when i click in the edit permalink button
- WordPress 3.4 Permalinks Redirection Problem
- Random Alphanumeric Key URLs
- Change permalink for a single post entry
- Remove the Parent category from the permalink but leave the child category
- Apostrophe in permalink results in page not found
- Change permalinks with ACF values
- Multilanguage URLs
- Confusion about how a URL is being parsed
- Attachment Page Permalink/URL Rewrite Issue. How to change the actual rewriting?
- wordpress api using rest_route for other pages
- Does changing a post title of a published post automatically change permalink?
- Remove custom taxonomy base from URL
- Rewrite rule intended for CPTs gives 404 for pages
- Unable to get /%postname%/ permalinks working, 404 on all links
- Permalink structure between 2 custom post types and a taxonomy
- Pre-populate Slug / Permalink with URL
- How to use all tags in post permalinks
- Disable date based archives for all categories except one
- How to rename ‘Tag Base’ with WPeC 3.8?
- Custom rewrite rule ignored
- add_rewrite_rule – Page Slug from “/foo-bar/” to “/foo/bar/”
- Change permalinks for specific pages
- Access or edit custom generated permalinks with WP_Rewrite
- optional parameter in permalink structure
- replacing post ID by custom post name in url
- All in One Seo and Permalinks
- Is it possible to change the permalink structure without changing the old permalinks to posts and without 301 redirects?
- rewrite based slug standar post wp
- I want to rewrite the URL of a specific post with a specific custom field to easily analyze in Google Analytics
- assets aren’t loading on a page but loads on others? slug permalink conflict?
- remove SLASH on single_post but KEEP on categories and parent pages
- Change Project permalink to custom URL
- How to create a standard WP Page that has the same url as an archive
- Add slug to default post permalinks ONLY
- How to change the URL using rewrite rule in wordpress
- Pretty Filter URL
- Converting WP Page to use full explicit paths?
- Prevent guessing slug
- Pages included in another page and duplicate content issues for SEO
- Customize category permalinks
- Update permalinks
- Losing the original URL when using add_rewrite_rule
- URL to an image in a post is changing when permalink is set to custom. Can I avoid this?
- permalinks url with woocommerce
- WordPress keep redirecting me to random URLs
- Blog url disappears
- Change default URL (or permalinks) in the back-end
- how to ensure url uses post_name and not query post id?