Skip to content

Instantly share code, notes, and snippets.

@zanematthew
Created September 15, 2011 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zanematthew/1218426 to your computer and use it in GitHub Desktop.
Save zanematthew/1218426 to your computer and use it in GitHub Desktop.
Template Redirect loopy
foreach( $this->post_type as $wtf ) {
$my_cpt = get_post_types( array( 'name' => $wtf['type']), 'objects' );
if ( is_tax( $wtf['taxonomies'] ) ) {
global $wp_query;
if ( in_array( $wp_query->query_vars['taxonomy'], $wtf['taxonomies'] ) ) {
if ( file_exists( MY_PLUGIN_DIR . 'theme/custom/' . $wtf['type'] . '-taxonomy.php' ) ) {
load_template( MY_PLUGIN_DIR . 'theme/custom/' . $wtf['type'] . '-taxonomy.php' );
} elseif ( file_exists( MY_PLUGIN_DIR . 'theme/default/taxonomy.php' ) ) {
load_template( MY_PLUGIN_DIR . 'theme/default/taxonomy.php' );
} elseif ( file_exists( STYLESHEETPATH . '/archive.php' ) ) {
load_template( STYLESHEETPATH . '/archive.php' );
} else {
load_template( STYLESHEETPATH . '/index.php' );
}
} else {
wp_die( 'Sorry the following taxonomies: ' . print_r( $wtf['taxonomies'] ) . ' are not in my array' );
}
exit;
}
}
@zanematthew
Copy link
Author

Correction, just noticed the variable $my_cpt is set but not used inside of the foreach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment