here is the function to get top parent category.
let suppose you have category
1 . English
-- sub 1 English category
-- sub 2 English
category
2 . Arabic
-- sub 1 Arabic category
-- sub 2 Arabic
category
and you are on the post page where it say current category sub 2 English
then you call function
$Parent = strtolower(get_top_category());
it will return top category name which is English
, after that condition will check if category is English then include 'single-English.php'
vice versa for Arabic.
function get_top_category() {
$category = get_the_category();
$cat_tree = get_category_parents($category[0]->term_id, FALSE, ':', TRUE);
$top_cat = split(':',$cat_tree);
return $parent = $top_cat[0];
}
echo '<pre>';print_r(get_top_category());echo '</pre>';
$Parent = strtolower(get_top_category());
if($Parent == "english") {
include 'templatepath/single-English.php';
}
else if($Parent == "arabic") {
include 'templatepath/single-Arabic.php';
}