With Slam’s kind tip to use query-monitor plugin, I could figure out what the problem was.
Apparently the url /search/foo/filter/bar
also fits the “general search” rewrite-rule. Makes sense, thinking about it– (.+)
technically matches /foo/filter/bar
aswell. So I could improve (.+)
by excluding /
s?
But I found an easier solution!
In hope “first match wins” I declared the more specific rule before the general rule– and e voila, it worked!
add_filter("rewrite_rules_array", function($rules) {
$newRules = array();
// more specific rule first
$newRules["search/(.*)/filter/(.*)/?$"] = 'index.php?s=$matches[1]&filter=$matches[2]';
// general rule later
$newRules["search/(.+)/?$"] = 'index.php?s=$matches[1]';
$merged = array_merge($newRules, $rules);
return $merged;
});
Related Posts:
- How to add a Rewrite Rule / Category Structure
- Change the permalink URL to include a taxonomy term
- How to Rewrite Taxonomy URL to Include the Post Type as the Second Segment of the URL?
- Add Taxonomy Subcategory To Permalink
- Custom URLs in Custom Search Results
- Rewrite Search URL Permalink For CPT Custom Taxonomies
- custom taxonomy and pages rewrite slug conflict gives 404
- Remove taxonomy base or term from url
- Using pre_get_posts to rewrite search query to display posts from multiple taxonomies
- Exclude Specific Term from Search
- WordPress database error: [Not unique table/alias: ‘wp_postmeta’]
- WordPress Search – display taxonomy terms in results
- Removing taxonomy base using WP rewrite
- Custom taxonomy on permalink
- How to find taxonomy name using only taxonomy TERM ID (or taxonomy term name)
- URL rewrite rules for multiple taxonomies query
- Rewrite rule for custom taxonomy
- How do I rewrite a url to use %taxonomy% instead of %category% when multiple taxonomies are present?
- Pros and cons of using [taxonomy name] in place of [category name]?
- WP redirects pretty permalink to query string
- Removing the base “Author” or changing it to something else. is it possible?
- Permalinks for quote authors
- Sorting Posts Via Custom Taxonomy Values Using Checkboxes?
- Change URL structure of subcategory archive pages
- add_rewrite_rule not working for language specific characters
- How to add custom taxonomy to search
- Add parent/child taxonomy to custom post type url
- Taxonomy.php issue with search and filters
- Extending wordpress search to include excerpts and taxonomies?
- how to search in custom fields & custom taxonomy for custom search
- Keep taxonomy base name in post permalinks
- How to create custom taxonomy URLs without taxonomy name?
- How to obtain the link/URL to the feed of a custom taxonomy?
- Permalinks for custom taxonomy stopped to work
- 404 error- issues with pages after adding custom rules for posts
- How to overwrite registered taxonomy url from vendor plugin in child theme
- Creating a custom search form
- Rewrite URL for taxonomy listing
- How do I keep the page I’m on within the URL when running a search on a taxonomy?
- Add multiple taxonomy filters to edit.php that support search
- Get Taxonomy Term Title by it’s URL
- Page and Post return 404 with custom taxonomy
- Extend & Search Native WordPress Image Galleries With Tags and Taxonomies?
- Taxonomy Pagination Rewrite
- Custom Taxonomy Not Working When added to WordPress Search
- WordPress thinks my custom taxonomy pages are search pages #seo
- how to change permalinks format for pagination?
- How do I create a permalink structure with 2 taxonomies
- Removing “s” from search with custom parameters
- Adding custom taxonomy in my existing category URL
- Taxonomy in URL
- Using custom taxonomies to display hierarchical URLs?
- Passing form inputs into multi-taxonomy query
- Pagination on Custom Tax Pages Removes Spaces from Query Vars
- How to change url for taxonomy pages?
- Search Query for Multiple Terms In Same Taxonomy
- Custom Taxonomy specific to a Custom Post type – rewrite URL
- Permalink Problems
- Why isn’t the ‘no results’ being shown when a query returns no results?
- Custom rewrite permalink doesn’t work
- forward/redirect taxonomy archive of term to a page with same name
- WordPress autocomplete search with taxonomies
- Double slash in the_terms URL
- Geographic search with taxonomy structure [duplicate]
- Custom Post Type URL Rewrite’s
- Permalink issues with custom taxonomies
- search using multiple taxonomies and keyword
- Taxonomy or Custom Field
- How to combine taxonomies into URL?
- Amend taxonomy to search in wordpress admin
- Include get_term_link inside search
- Product custom taxonomy is not found when space in name
- Change the full permalink (URL) of a single post by connecting it to a specific page
- Taxonomy page loading wrong data
- Taxonomy URL rewrite whilst keeping filtered posts?
- How to change search page url so that it still returns a page when there’s no search query specified?
- Search custom taxonomy via query-string?
- How can I rewrite the URL of my custom taxonomy to include the year?
- How to change Custom Permalink for Taxonomy? (remove the slashes from term-slug)
- How to exclude woocommerece product category in search results?
- How to structure all custom-taxonomy with three verbs(a,b,c) and route them accordingly?
- Remove taxonomy name and add .html extension in the custom taxonomy term URL
- Passing taxonomy id of taxonomy clicked on one page to another page
- Hierarchical taxonomies in permalink cause 404 for sub term archive
- Permalinks incorrectly inserting multiple categories
- WordPress custom taxonomies new/edit post autocomplete
- Permalink structure not working with Custom Taxonomy (URL like ./taxonomy/category/postname)
- Post not showing in my custom advanced search
- Force WordPress to only match URL in category
- Need help understanding a rewrite with multi-level taxonomy
- How to perform a search inside a specific taxonomy category
- Where is defined a custom register_taxonomy? [closed]
- Customize category URL
- get multiple values from $_GET from multiple checkboxes
- Multiple Taxonomy in URL/Query – No Custom Post Type
- Creating a page for custom taxonomy archive
- Advanced WordPress search form based on custom taxonomy and custom meta value
- Custom Search only for my Custom Taxonomy Page – data
- Search and filter with custom field in taxonomy
- Custom Post Type with multiple Custom Taxonomies / Hide Taxonomy Slug from URL