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:
- esc_attr() right way and use
- Is having multiple theme customizers for different pages possible?
- Detection of theme being used
- 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’
- Replacing mysql_real_escape_string in WordPress theme
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- Can’t Find a Way to Edit the Home Page Content [closed]
- Use different javascript files for each page on website
- Fatal error: Call to undefined function wpsc_cart_item_count()
- How to get custom image size for image uploaded in Customizer
- Widgets not showing in my custom theme
- 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
- How the functions in WP are called in tags
- Add a Second Menu to a theme that only support 1 menu
- 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)
- Can’t load WP function into external function
- 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
- WordPress add post format support not working
- WordPress: Access a plugin from within a theme
- Connect WordPress with SharePoint [closed]
- 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?
- My page.php shows the index.php
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- How do I link a button I created in theme customizer to a function?
- 404 error when I acess the second page of post-type
- 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?
- Does wordpress templates always in files or in database?
- proper way to add css using functions.php?
- Showing latest post without 301 redirect
- Translate wordpress date from Italian to English
- Why am I getting a different filename? And how does WordPress load singular.php for both Page & Post? (Fresh WordPress installation)
- Reason to add a name of the theme like (‘menu-1’ => __( ‘Primary’, ‘twentynineteen’ ),) in PHP?
- Separation of presentation and code – WordPress
- Do I have anything to worry about when switching to a default theme to test for plugin conflictions?
- get_template_directory adding FTP root folders in urls
- How to integrate noimage picture in this code
- Need oop for wordpress theme? [duplicate]
- Warning: printf(): Too few arguments in helpers.php file
- WordPress and PHP Version Upgrade issue [closed]
- 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]
- Amend theme php to include certain category in header
- Accidentally deleted php code in WordPress website [closed]
- How can I assign separate stylesheets to different pages?
- How to make sure relative URL works when site is not on root domain?
- Editing Theme Files on WordPress.com-hosted Site [closed]
- Some problems calling a function into sprintf() inside functions.php template file [closed]
- Is there a (offical) way for a theme to deactivate itself and show a message in admin?
- Wrap title and excerpt in a div (latest posts block)
- how to get wordpress page url php code [duplicate]
- How to set all External Domain Links with nofollow Attribute from Header Footer Content and Excerpt using PHP?
- How to put search bar & logo in the “primary navigation” storefront theme?
- Dynamically switch file in get_template_directory_uri() | Function [closed]
- Uncaught TypeError: extract(): Argument #1 ($array) must be of type array, null given
- Styling a category link
- remove_action from parent theme using child theme functions.php
- Commenting requires wordpress login, wordpress discussion and post comments tick boxes are checked
- Conditional Banners
- Force Sidebar on Full Width page
- The style.php file inside theme-engine folder has other content on FTP
- How to override theme’s public static function inside of a trait?
- How to Change Site Elements based on referring URL
- how to use 2 index.php file One for mobile and one for desktop
- PHP Error in WordPress Theme
- loop to return tags in woocommerce in alphabetical order?
- need to edit php file of child theme to remove an element
- How to add Open/Close Toggle button into Twenty Fifteen theme for hiding left sidebar?
- Use Custiomizer to setup meta theme color tag
- Rotating Header Images
- Custom Theme, Editor won’t wrap text (i.e. change width)
- Editted Theme Files Get Updated/Reverted Every So Often
- WordPress pagination broken on blog page, working for search results page
- two wordpress sites, two themes, one database, same content
- calling a function from a class in your template
- Showing custom field contents without listing description
- Hide cart when empty [closed]
- WP Knowledge Base Theme bug – Subcategories and Articles, Need to change WP_Query
- Shortcode Display From WordPress Dashboard Page Without Using post_id
- Inserting A Feed and Sidebar into an HTML Page
- how to register a second page-template
- Gallery requires a featured image but does not show it in posts/pages
- How can I print out a single stylesheet or javascript link?
- Link a lightbox thumbnail to a post instead of opening the lightbox
- Predefine Magazine Style Layouts
- How to store the_post_thumbnail() value in a variable
- a problem in class in class-wp-hook.php
- Using Featured Image as Hero Background in Word Press