You could achieve this with a filter on category_template
. This would go in your theme’s functions.php
file. See the comments in the code for an explanation of what it’s doing:
function video_category_archive( $template="" ){
// your parent video category ID
// ( change this to your actual video category ID )
$video_cat_id = 42;
// get the ID of the current category being viewed
$cat_id = get_queried_object_id();
// get the IDs of the ancestors of this category
$ancestors = get_ancestors( $cat_id, 'category' );
// if this category is a child of the video category,
// or if this is the parent video category,
// load the post type archive template
// instead of the normal category template
// ( change archive-video.php to the name of the template you want to load )
if( in_array ( $video_cat_id, $ancestors )
|| $cat_id == $video_cat_id ){
$template = locate_template( array( 'archive-video.php' ) );
}
return $template;
}
add_filter( 'category_template', 'video_category_archive' );