Created
December 7, 2011 20:42
-
-
Save billerickson/1444548 to your computer and use it in GitHub Desktop.
Template Chooser
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 Chooser | |
* Use CPT archive templates for taxonomies | |
* @author Bill Erickson | |
* @link http://www.billerickson.net/code/use-same-template-for-taxonomy-and-cpt-archive/ | |
* | |
* @param string, default template path | |
* @return string, modified template path | |
* | |
*/ | |
function be_template_chooser( $template ) { | |
if( is_post_type_archive( 'recipe' ) || is_tax( 'name-range' ) || ( is_tax( 'base' ) && 'recipe' == get_post_type() ) ) | |
$template = get_query_template( 'archive-recipe' ); | |
return $template; | |
} | |
add_filter( 'template_include', 'be_template_chooser' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment