I tried to create a category template apply for parent and child specify category. I has create a file name 'category-1.php , in this file I used the loop for get the list of post:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
// Show content of category post here.
<?php endwhile;?>
<?php endif; ?>
In the function file, I put this code:
function wpd_subcategory_template( $template ) {
$cat = get_queried_object();
if( 0 < $cat->category_parent )
$template = locate_template( 'category-1.php' );
return $template;
}
add_filter( 'category_template', 'wpd_subcategory_template' );
I get the posts of child category ok, but the post in parent category not show full ( current 10 posts ). Has anyone tell me why ? Thank you.