admin管理员组文章数量:1425742
Sports
- live score
- standings
- Transfer
As seen above...the parent category is Sports with three subcategories (live score, standings and transfer)...Can each of these subcategories have a different custom category template...that is each subcategory with unique template
here is my code below...
// Different template for subcategories
function wpd_subcategory_template( $template ) {
$cat = get_queried_object();
$children = get_terms( $cat->taxonomy, array(
'parent' => $cat->term_id,
'hide_empty' => false
) );
if( ! $children ) {
$template = locate_template( 'category-sports-livescores.php' );
} elseif( 0 < $cat->category_parent ) {
$template = locate_template( 'category-sports.php' );
}
return $template;
}
add_filter( 'category_template', 'wpd_subcategory_template' );
本文标签: categorieshow to give different template to each subcategory from same parent category
版权声明:本文标题:categories - how to give different template to each subcategory from same parent category? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745439390a2658376.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论