Last active
April 6, 2017 14:34
-
-
Save javierarques/5444534 to your computer and use it in GitHub Desktop.
Wordpress. Set custom template for taxonomies. Change default template. template_include filter
This file contains hidden or 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
// Add the filter | |
add_filter( 'template_include', 'my_custom_template'); | |
/** | |
* Returns customized templates for custom taxonomies | |
* | |
* @param string $template | |
* @return string | |
*/ | |
function my_custom_template ( $template ) { | |
if( (is_tax('custom_tax')) | |
&& is_main_query()) { | |
$template = TEMPLATEPATH . '/page-custom.php'; | |
} | |
return $template; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment