Skip to content

Instantly share code, notes, and snippets.

@javierarques
Last active April 6, 2017 14:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save javierarques/5444534 to your computer and use it in GitHub Desktop.
Save javierarques/5444534 to your computer and use it in GitHub Desktop.
Wordpress. Set custom template for taxonomies. Change default template. template_include filter
// 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