Skip to content

Instantly share code, notes, and snippets.

@aliciaduffy
Last active December 31, 2015 01:09
Show Gist options
  • Save aliciaduffy/7912196 to your computer and use it in GitHub Desktop.
Save aliciaduffy/7912196 to your computer and use it in GitHub Desktop.
WordPress override template hierarchy/suggestions
<?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