Confusingly, get_the_category()
returns an array of categories, so you’re going to need to loop through them.
It sounds like you want whichever category is assigned to the current post, and is also a sub-category of category id 11. If that’s the case, use
<?php
// Get all the categories assigned to this post
$categories = get_the_category();
// Loop through the array that was returned
foreach($categories as $category) {
// If this category is a sub-category of category 11
if($category->parent == 11) {
// Set the $parent to it
$parent = $category;
// And exit the foreach loop
break;
}
}
?>