Last active
December 31, 2015 01:09
-
-
Save aliciaduffy/7912196 to your computer and use it in GitHub Desktop.
WordPress override template hierarchy/suggestions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Template hierarchy overrides | |
* Use taxonomy or archive templates for specific cat and search queries | |
*/ | |
function duffy_override_category_template( $template ) { | |
if ( is_category() && ( 'custom-tax' == get_query_var( 'taxonomy' ) ) ) { | |
return get_stylesheet_directory() . '/taxonomy-custom-tax.php'; | |
} | |
if ( is_search() && ( 'custom-type' == get_query_var( 'post_type' ) ) ) { | |
return get_stylesheet_directory() . '/archive.php'; | |
} | |
return $template; | |
} | |
add_filter( 'template_include', 'duffy_override_category_template' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment