You can use the tag_template or taxonomy_template filters and check the queried object from within that, then use locate_template to get the template path.
function wpd_tag_template_filter( $templates="" ) {
$this_tag = get_queried_object();
// check $this_tag->term_id, $this_tag->slug, etc.
$templates = locate_template( 'my_custom_template.php', false );
return $templates;
}
add_filter( 'tag_template', 'wpd_tag_template_filter' );
Related Posts:
- Check php version before theme activation
- Permanently remove first image from posts
- reason of splitting theme files to multiple files
- Set the transport of the Customizer ‘header_image’ core setting to ‘postMessage’
- One button to change all settings in theme customizer?
- Twitter feed is showing blank in WP site [closed]
- Design view breaking on Pages
- Use different javascript files for each page on website
- How to get custom image size for image uploaded in Customizer
- Passing array in add_option()
- Want to create Child theme, but already edited Parent theme css files and some php files
- Adding code to child theme functions.php to override parent theme behaviour doesn’t work
- Create a quick start wordpress installation [closed]
- How should I best target dynamically served content?
- Changing the template hierarchy
- How to Insert Shortcodes into Theme?
- Warning: Use of undefined constant HTTP_USER_AGENT – assumed ‘HTTP_USER_AGENT’ (this will throw an Error in a future version of PHP)
- Set WordPress Default Template
- Custom Theme, Custom shortcode not working
- Customizer: Output default value in Customizer CSS
- WordPress does not load page.php, return 404.php
- Adding custom directory and PHP files in wordpress
- Where in PHP do I move title and meta (date) to bottom of each blog section?
- Show full posts in archive
- WordPress add post format support not working
- Connect WordPress with SharePoint [closed]
- Reconfiguring WordPress site
- adding custom user input fields in WordPress admin dashboard gives error The link you followed has expired. Please try again
- Move category description below post list in blog
- WordPress Shortcodes.. printf is outputting a random number… Can’t figure out WHY?
- Customizer: active_callback and sanitize_callback incompatibility?
- How do I link a button I created in theme customizer to a function?
- How to change theme programmatically from a external application?
- Is the “_s” on this `sprintf(__(‘Page %s’, ‘_s’), max($paged, $page))` just refer to a text domain?
- Reason to add a name of the theme like (‘menu-1’ => __( ‘Primary’, ‘twentynineteen’ ),) in PHP?
- Separation of presentation and code – WordPress
- WordPress Customizer Default Image
- Why in my theme I can’t see all the statics content under the posts?
- get_template_directory adding FTP root folders in urls
- How to add the sidebar to all the pages except the home page? [closed]
- Header not properly displaying on archive.php
- Design with Elementor and code the rest?
- How Do I Find & Remove H1 From Site-Title-Wrapper? [closed]
- blank white page when post/update/change option etc
- How to Update an old theme for the latest wordpress version
- get_comments_number() returns 0
- Fatal errors to undefined function in theme 404.php file [closed]
- Problems clearing cache
- ‘Bones’ theme: Load stock scripts in footer instead of header?
- How to correctly load a different version of main menu based on the user language in WordPress? Is it a good solution?
- Why in this WordPress theme I can’t see the Main Menu?
- Displaying Slider in Front Page (home) using Customizr Theme
- Editing Theme Files on WordPress.com-hosted Site [closed]
- call a string/function from database
- Some problems calling a function into sprintf() inside functions.php template file [closed]
- WordPress redirects page query parameter in URL
- How to set all External Domain Links with nofollow Attribute from Header Footer Content and Excerpt using PHP?
- Publish button now showing content after saving
- Uncaught TypeError: extract(): Argument #1 ($array) must be of type array, null given
- error_log PHP error log found. This file must not be in the production version of the theme. (wordpress theme check plugin)
- How do I use an iFrame for my header in WordPress twenty seventeen?
- When I click for the redirect link it is showing the content of index.php instead of single_assignment_page.php
- remove_action from parent theme using child theme functions.php
- File from parent theme imported to child theme doesn’t work – any ideas?
- How to use data URL in WordPress?
- wordpress email checker on domain
- Unable to retrieve get_author_posts_url
- Display post date also if the date it’s the same for each post
- Force Sidebar on Full Width page
- How can I render more than multiple posts on template-parts with post formats
- Add the shortcodes from the enfold theme to the other theme
- WordPress child theme, creating a custom php template page
- How to get Post sidebar & footer including html like get_the_content() which only gets content section?
- Menu to the right of screen on desktop using Bootstrap 4
- style.min.css code issue
- Beginner Developing Theme with Bootstrap – NavMenu question
- Local WordPress from Git repo, where to set document root?
- user update profile for custom code
- Create a custom theme-specific page, invisible in the admin-panel?
- Editing existing pre-created menus in PHP
- Shortcode Display From WordPress Dashboard Page Without Using post_id
- Image not displayed
- Include a php file that is above WP installation hierarchically?
- Using existing widget code! [closed]
- WordPress Website Featured Image Replacement Issue
- doubled content
- Themes with variable width or single columns? I want to display source code
- .htaccess on multisite and roots theme?
- Move wordpress sidebar on homepage up to new position
- How can I print out a single stylesheet or javascript link?
- Errors while Loading Most Recent Version of jQuery
- WordPress menu links with images & class selection
- Predefine Magazine Style Layouts
- How to remove the intro animation which appears during the load up of some WordPress themes? [closed]
- How to store the_post_thumbnail() value in a variable
- Need help with Deprecated: Non-static error when update PHP 7.4 -> 8.1 with Dyad 2 theme
- Font Awesome Icons as squares [closed]
- Gulp dev environment set up for WordPress theme development
- What is considered good practice for registering menu locations?
- WordPress generating Undefined Variable warning