Updating category template to change how subcategories display

You will need a simple check inside your loop which logic is quite also simple. The logic behind this is as follow:

  • If a post belongs to the current queried category (AKA the parent category), it will have this category attached to it

  • If a post belongs to only a child category of the current queried category, then it will not have the current queried category attached to it.

With this is mind, we only then need to determine if the current post have the queried category assigned to it. For this, we can use the conditional check, has_category(), to determine if the post has our desired catgeory or not, and then use get_queried_object_id() to get the ID of the current category beign viewed

Inside your loop, you can do something like the following:

$current_category_id = get_queried_object_id();
if ( has_category( $current_category_id ) ) { // Post belongs to the queried category
    // Add your specific markup and code for current queried category
} else { // Post belongs to a child category
    // Add your specific markup and code for child categories
}