Reputation: 487
How do you add a category template via a Wordpress plugin. It needs to be for a specific category. So if the category is 'category-awesome' load 'category-awesome.php'. I've come across using the single template hook e.g:
add_filter('single_template', 'my_custom_template');
But haven't found anything for categories or a single category.
Many Thanks
Upvotes: 1
Views: 453
Reputation: 487
Think I solved it. Use the template include filter hook:
function category_awesome( $template ) {
if (is_category( 'awesome' )) {
$new_template = dirname(__FILE__) . '/custom-template-awesome.php';
if ( '' != $new_template ) {
return $new_template ;
}
}
return $template;
}
add_filter( 'template_include', 'category_awesome' );
Upvotes: 1