You will need to first setup a way to get the category of the current page. Maybe something using get_the_category() or similar. Then after you have done that you want to set the selected
argument to the ID of the category you want to be selected. Right now you have it set to -1
.
See the description of selected
here.
Related Posts:
- Display search results within the same page
- How to insert a span inside a search form?
- Why is there a class=”screen-reader-text” on my search button?
- How to make a search form?
- how to create search and filter form generating “plus” symbols in url in between category names?
- How to load WP categories into array for autocomplete?
- Risk of sql injection for custom search form
- meta_query issue with multiple numerics
- Why is this search form not submitting when button is clicked?
- Why should we use the name attribute with the value “s” in the creation of the search form?
- How to have multiple instances of the same taxonomy in a search form
- Page 2 of Search Results shows homepage
- How to Fix Form elements do not have associated labels in WordPress Search Form (without button)
- Form for search pages by meta datas
- WordPress search with more input fields?
- Editing a Search Form
- Create a custom and powerful search form
- search form display no result
- How To Change Url Doing Some Changes in Search Form
- Search Results with googlemaps
- Adding attributes to the core search block form
- Consistent and Admissible Heuristics
- Solr vs. ElasticSearch
- How do you make Vim unhighlight what you searched for?
- grep for special characters in Unix
- How can I customize wordpress content egg searh form?
- Search is always exact [closed]
- how to limit search to post titles?
- How to create live autofill search?
- How can I implement a location based (zip code) search in WordPress?
- How to highlight search terms without plugin
- How do I remove Pages from search?
- Empty search returns home page, how to return not found search page?
- How to search for (partial match) display names of WordPress users?
- How to make search include data from wp_postmeta?
- How does WordPress search work behind the scenes?
- Remove some pages from search
- Limit search to latin characters
- How to look at code in WordPress repositories without downloading?
- Extend WordPress search to include user search
- Empty search input returns all posts
- How can i move search results onto a specific page?
- Remove meta robots tag from wp_head
- WordPress blog with 30 000 posts: poor search performance
- Template issues getting ajax search results
- Insert DIV container below 1st search result
- Unified search across separate WordPress installations
- Search in WordPress – Difference of searchpage.php, searchform.php and search.php?
- How to make WordPress search prioritise page titles?
- How to add the author search in the default wordpress search?
- How to correctly submit a search form and display the result in an independent page
- How do I filter the search results order?
- How do I redirect /search/ to wordpress search template?
- Genesis – Customize search form
- How to search for users based on added user metadata
- Search by Post ID and display content of the post in search result
- Extending search query with additional $sentence value
- Link to search page without search parameter
- Search/Replace for editor in HTML-mode
- How do I search events between two set dates inside WP?
- Search only blog posts (default WP search widget)
- Exclude pages from WordPress search result page
- How to pass a search $_GET parameter to a new custom search page?
- Do I need to sanitize WordPress search query?
- Disable Redirect to Product Page on Search Results Page in WooCommerce [closed]
- Search Using Post ID
- Neither the_excerpt() nor the_content() works properly?
- Let user change posts per page
- WP User Query with search columns and meta query
- Exclude top-level pages from search results
- WordPress 3.6, searchform.php problems
- Search in non-English language returns only one result
- Complex Search functionality. Advice needed
- How to exclude pages from the search results
- Get user role by using user_id in buddypress
- How to use next_post_link and previous_post_link on single posts in search results
- template_include for search.php makes WordPress think its on the home page
- Turning Broken URLs Into Search Terms?
- How can I implement faceted search with WordPress 3.x?
- can’t limit search to only pages
- Add custom parameters to JSON API search query?
- Combining Meta_Query key values for one array
- Change the Search Base in a multi language wordpress
- Display posts from an author using search parameters (not author template/query_posts)
- Search: Only One Result Returned
- Pagination not working for Custom search form & custom result template
- Include custom table into search results
- How to redirect search result page to post
- Create multiple Search functions for posts / custom post types and everything
- How to stop _wpnonce and _wp_http_referer from appearing in URL
- Return all Tags from search results
- How to exclude post body from WP search
- Custom Permalinks Break Search Pagination
- Search results with custom loop don’t update when paged
- ElasticPress Indexing multiple sites
- Search uses index.php instead of search.php on renaming search field from “s”
- How to search through pdf media files?
- Search outside of the “loop”
- Replace URL with Site Title in Search Results
- How do I change WP search results order?