You can force WordPress to load search.php template when you need it by using the following code:
add_filter( 'template_include', 'get_search_template' );
instead of
$q->set( 'is_search', true );
Related Posts:
- Create multiple Search functions for posts / custom post types and everything
- pre_get_posts and search query for admin
- Search function works improperly
- How to conditionally pass a parameter to wordpress search to limit post types?
- How to exclude pages from WP search based on page title
- why pre_get_posts works fine in post type archive, but not in search result list?
- Search for two strings in WP search
- Displaying number of search results for each post type
- Use pre_get_posts to display search results by meta in specific order
- Search custom posts by meta key in admin
- pre_get_posts improperly searching revisions
- WP search in metadata post
- meta field search too restrictive in pre_get_post() for custom search
- search filter for search and tag page doesn’t work
- how to limit search to post titles?
- How does WordPress search work behind the scenes?
- Remove some pages from search
- WordPress blog with 30 000 posts: poor search performance
- How do I filter the search results order?
- Link to search page without search parameter
- Order Search Results Page by meta_value If no Value Return Remaining Results
- Search/Replace for editor in HTML-mode
- Do I need to sanitize WordPress search query?
- Neither the_excerpt() nor the_content() works properly?
- Add custom parameters to JSON API search query?
- How to stop _wpnonce and _wp_http_referer from appearing in URL
- Return all Tags from search results
- Does WP search natively return results sorted by type (post, post type, page, category…)?
- How do I properly redirect outbound links with special characters
- Display Categories in Search Results
- intellisense in wp search
- Is it possible to search authors by profile field?
- Search result conditonal tag
- Get search term not on searh results page?
- Search Result from another wordpress website
- Two Search Boxes: one all content, one only titles
- Keep query string in url after executing a serch
- How can I remove the search window?
- Customize search page
- Customise search page depending on result
- How do I use a block to display search results?
- How to make search include data from wp_postmeta?
- Use “search” in permalink?
- Can I change the default search behavior “OR search” to “AND search”?
- Risk of sql injection for custom search form
- Filter post_type thumbnail in Search result
- Home page shows recent post, serps rank post within homepage
- How to set empty search to load homepage template and not index.php
- Post 2 Post Site Search
- Using search.php without a ‘s’ field in searchform.php
- Array_search ignoring the first element [closed]
- Add Icon to Placeholder Text in Search Form
- Unexpected esc_html and esc_attr behaviour
- WordPress search page doesn’t work with either $_GET or $_POST
- Search Results No Link
- Sort search results by Custom Field
- Strip HTML Tags From Search Results
- How to build an advanced search form by post type?
- Why WP_Query’s ‘s’=>’keyword’ searches only for ‘post_title’ and why not ‘post_content’?
- adding more text to a query string
- Independent search tool that returns exact match of a post title
- Search using WP_Query
- When clicking on submit from my searchform it takes me to home.php
- My default search is not working
- Dashboard search function doesn’t work well
- twentyeleven theme: Where is the code that handles moving the search bar on resize?
- Displaying a list of tags in my archives page
- Page 2 of Search Results shows homepage
- Amend taxonomy to search in wordpress admin
- Extend product search to search in attributes
- Return All Tags from Search Result in Separate List
- Custom database table and custom search
- Can I replace the search bar with Programmable Search by Google?
- Banning special characters in search form input
- Search within the current page
- What are the available options for “Name” in WP search?
- how to make search with two input boxes
- WordPress search with more input fields?
- WordPress search not able to find the category
- Editing a Search Form
- how to prevent the spam on search function?
- I have dynamic title tag in my wordpress but seo analyst show “No title Tag found error”?
- Why is wp_dropdown_categories not searching within the sub-categories in my custom taxonomy
- limit the number of searches
- How can I prevent the Search Results Page from changing title?
- Problem with site’s search results “Read More” link?
- Custom Post Search
- Custom search page and url in multilanguage
- Make the title and […] clickable in result search
- Search multiple custom post types with tags
- Strip the + symbol from the_search_query
- Putting Text in the Search Box. eg- “Search My Site” [closed]
- How to remove search bar from the blog post
- Search and replace titles of posts with specific tags
- How do I turn this form into a search form? [closed]
- Making ACF fields appear in search results
- How to make wordpress Dynamic Search-icon from Predesigned Static Html Search-icon?
- search ALSO by POST-ID with a public front-end search box
- how to create a multi selector dropdown search box by code?
- Display search results within the same page in wordpress