You can tell WordPress to use the search.php
template whenever viewing tags by using the template_include
. It works like this:
function wpse_240429() {
// IF we're planning on loading a tag template
if( is_tag() ) {
// Try to locate the search.php template
$search_template = locate_template( 'search.php' );
// If the search template exists
if( ! empty( $search_template ) ) {
// Use search.php for display purposes
return $search_template ;
}
}
}
add_action( 'template_include', 'wpse_240429' );
You shouldn’t have to mess with things like pre_get_posts
as the query should already be pulled.
Related Posts:
- WordPress hierarchy clarification, does post_type_archive take precedence over taxonomy-term archive?
- Pass PHP variable to javascript
- Is it possible to stop selected plugins from loading on certain template pages?
- Page Templates from plugin not working after upgrading WP to 4.7 or upper version
- Creating a default Custom Post Template that a Theme can override
- What is the correct way for a theme to support plugin UIs?
- How to call “page specific menu items” in template [closed]
- Update Multiple Post Meta for the Same Post In One call?
- Function to activate WordPress theme inside a plugin
- Which functions in theme or plugin load first
- How can I add a custom header to a custom template in a plugin without using the theme folders
- How to make my plugin theme-independent?
- How to load a new template page according to a particular URL?
- Should I use RIPS tool to test my themes and plugins?
- Custom url structure for custom template
- Autoload via composer in plugin interference
- Workflow and best practice for documentation [closed]
- Get image URL from media library in input
- Display future posts?
- Having separate plugins and themes folder for multi-site setup
- How can I get full attachment url from wp_get_attachment_metadata?
- Where to put my global functions?
- unzip a folder on specific location and delete the zip file
- gallery option is not available in media upload box in costum theme option page
- Why is the Settings API is not saving my array of options
- Override comments.php template with plugin
- How to integrate plugin in WordPress theme
- Is there any way to get all the name or slug of template parts used in a page?
- Can we use a webservice with WordPress?
- WooCommerce get_price returning wrong price when used via ajax
- Open Post Thumbnail in New Child Theme File in WordPress
- How to use get_theme_mod in gutenberg editor wordpress?
- How to get current post user id
- WP Post Template – Templates in own folder
- Register Page Template from Plugin
- Display post lists in 2nd paragraph
- Plugin-generated pages use Not Found or Pages Archive templates?
- What are the specifics of WordPress development I need to know? [closed]
- How to create a code editor for my plugin .?
- Perform internal redirect in WordPress?
- How to use get_template part in the plugin?
- Redirect to another page using contact form 7? [closed]
- Great blogs site resources/tutorial for WordPress Developers? [closed]
- How to write “alt” tag in image for wordpress code?
- Default taxonomy template in plugin, override in theme
- Release the plugin in the WordPress repository where redux is used
- Shortcode Attributes to Return different $_POST
- How to use the CSS of the WordPress core in the development of my administration page?
- How to use template inside plugin shortcode with variables for big HTML code
- WordPress API functions not working at AJAX functions.php call
- What’s the right way to implement functions in footer.php
- Don’t load the theme for a page FROM a plugin EDITED
- Extending a theme: build new features as plugin or core modules?
- Remember the Meta Value With Radio Buttons
- How do I show content from a plugin using the template the site is currently working with?
- How do you create a re-useable HTML fragment in wordpress
- WordPress plugin with its own “site”/theme
- Yoast SEO Plug In and my Theme duplicating code. Need some feedback on what to do? [closed]
- Xamp installed local wordpress not allowing to publish or install plugin
- Widgets are not displaying in the admin panel
- How to override any plugin file in the child theme
- submit two file input fields in the same form
- Content-Security-Policy implementation with WordPress W3Total Cache plugin installed
- woocommerce: Customize email with item total count
- Child theme modifications not showing up
- Rename a folder via HTML POST request
- How can I see $post object in frontend from functions.php?
- when i activate my WordPress plugin cannot see customizer options or preview
- How to prevent redoing get_posts queries and make results available to other scripts?
- Change Jobs for WordPress templates
- how to do Thematic like this website using wordpress?
- Remove action added in plugin class from theme
- Can you develop themes and plugins while using the hosting services BlueHost? [closed]
- Help Code Review – I need to write on .htaccess file from theme’s function.php
- how to add custom css at top above all css file for specific url
- Where do the section input fields values are stored in database
- Why the output of an image gallery plugin is not displayed into a page of my custom theme?
- How to add dynamic content to posts page, archive, taxonomies, search, author, etc?
- Convert HTML5/CSS3 site to WordPress Theme (need a lot of plugins) or just use the API?
- How to show post attachment image
- Can anyone tell me why I can’t edit a plugin when it is installed without having to re-install?
- show Visual form builder in the front end
- What is the Object for WP_Error Class?
- Active Plugins for current blog in WP Multisite Network? [duplicate]
- Breadcrumb is not generating the correct post page url
- Site is setup statically – how to make it content managable?
- How can I make a website with dynamic features with wordpress?
- How to generate a responsive output from plugin?
- How to add image for custom taxonomy
- Integrating WordPress Content into a jQuery Slider
- How to escape html code?
- manage_{taxonomy}_custom_column not working
- how to make wordpress remember my choice
- How to Enfroce Domain Licensing Limits? [closed]
- Meta box not displaying on the plugin page
- add_meta_box showing blank screen in my page
- How to make a Template page to show the information of different things Shop and Product page?
- How to make content as required in custom post type?
- What are Seeds? [closed]
- How to provide page_template path in custom plugin using WordPress