You can use template_include
filter hook
add_filter('template_include','my_custom_search_template');
function my_custom_search_template($template){
global $wp_query;
if (!$wp_query->is_search)
return $template;
return dirname( __FILE__ ) . '/my_search_template.php';
} /*UPDATE: there was a missing ";" after $template*/
Related Posts:
- Restrict a search to a custom post type
- When calling wp_title(), do you have to create some kind of “title.php” file?
- Modifying searchform.php and search.php to have two kinds of searches
- Set template based on query in URL
- Unable to create custom search results template page
- Which has more impact on site performance? Template overrides or hooks
- Is there an action hook that fires just before a template is loaded?
- get_search_link() redirects to 404 template page
- Search results when none found – stay on page they were on
- Redirect template based on permalink rather than $wp_query
- Standard WordPress Search does not work / Search-results are not displayed / Custom template
- How to identify which template WordPress’s default search-form retrieves in my theme
- if page is parent page redirect to first child with hook / polylang
- How can I add text to a specific ‘Edit Page’?
- Genesis – Adding custom hooks to display secondary navigation
- Conditional to determine if search.php page is the current template
- How to use another file instead of home.php
- use a custom page to display search results
- Can i exclude certain page templates for a specific role?
- How to add description over forum list on bbpress root page
- What filter or action hook to use in order to load some code before the template begins printing in BuddyPress? [closed]
- How to name custom search page PHP file?
- Search button click sends to single-custom_post_type instead staying at the same page
- how to change custom post type search template to output search results in posttype-archive.php
- Where is search.php?
- Is it possible to return a specific tag archive/template as one of the search results?
- Retrieving post ID from current page
- Given a page ID, how to display entire page (header/content/footer/sidebars) from a plugin hook
- Search results in custom template
- How to use Class
in Java? - Get name of the current template file
- How do you find out which template page is serving the current page?
- How to change the default registration email ? (plugin and/or non-plugin)
- How do I get the size of an attachment file?
- Is there any way to use get_template_part() with folders?
- how to limit search to post titles?
- Adding Page Attributes Metabox and Page Templates to the Posts Edit Page?
- How can i change email template for new user
- Any advantage to using get_header() over include(‘header.php’)?
- Enable page templates. How?
- Is it possible to override the result of get_template_part()?
- Use [embed] filter in template files
- Searching multiple custom post types and pages
- What’s the purpose of the paged.php file?
- How do you access the Product Short Description in a WooCommerce email template? [closed]
- Prevent comments_template() to load comments.php
- Is there a way to list all used/unused WP templates?
- Page editor missing Templates drop down
- How to redirect to post if search results only returns one post
- Print WordPress template filename(s) for debugging
- How to add a new product type on woocommerce product types? [closed]
- How to force TinyMCE in WordPress to replace newlines with tags and not with
- How to find the posts page (home page) programatically
- WooCommerce: Change template for single product page
- View WordPress page template usage (or unused)
- How to edit contents of dynamic_sidebar()?
- How to check if a shortcode exists?
- Where is get_header(‘shop’) file in Woocommerce templates
- Custom templates folder
- Template issues getting ajax search results
- What is the link to my default “archive” page?
- How to get slug of current category in taxonomy template?
- How to show a under construction page for a domain but still be able to work on index.php?
- Change the name of the ‘Default Template’
- Customizing get_the_excerpt() to specific length and “Read More” output.
- How to Rename a Template File?
- get page templates
- Echoing Elementor page content in template, but it doesn’t get styles and some widgets are missing
- Using WordPress templating for HTML emails
- Loading partial templates with AJAX/PJAX
- WP frontend output of custom textarea fields not respecting line breaks. In admin it’s OK
- How do you check if a WordPress template file exist?
- Load entire NextGEN gallery from single thumbnail?
- I put my blog on a subpage, how do I get page title?
- A special single page templates for posts under a category and all its child category
- Custom reset password template after forgot password request
- Outputting Canonical Resource URLs Across a Multisite Network?
- Gravity Forms Custom Templates [closed]
- Child Theme: how to override variables?
- How do I get the URL of a specific size featured image?
- Want to redirect if search query match exact title of any post
- Where to store some per-template preferences?
- add/apend templates ‘transparently’ via plugin to currently active theme or child theme?
- stop blog page from using index.php?
- How can I modify the default reset (lost) password email text?
- How to create tag.php
- Template files missing after moving site
- How do I override template-tags.php in twentyseventeen theme
- Get template part vs locate template function
- Programmatically change post templates?
- How to hide/redirect the author page
- Tools for Converting an Existing Website Design to a WordPress Template?
- Gutenberg & Pre-formatted Templates: Core Block Attributes
- How to customize search result page title?
- Gutenberg Editor – Template Doesn’t Match Error
- author.php added to template not working on Nginx server
- Test if page is child and has children, if so echo child pages also on grandchild pages
- Load different template file when condition met?
- Need to give custom page template for each language in WPML
- roots child theme can’t override header.php