You are currently adding two parent categories: Events and Magazine.
The magazine has child categories associated with interviews and reviews.
Below is a hierarchical representation of the current category. There are currently no posts in the Review category.
Events
Magazine
Magazine > Interviews
Magazine > Review
This is the main point. I want to know how to get the parent category ID from the current category ID and list the names of the child categories.
Below are the problems that are occurring.
If you access and confirm a child category that does not have a post, an unrelated event category will be output.
It also prints an error.
Notice: Undefined offset: 0 in /var/www/html/custom/wp-content/themes/cocrework/category.php on line 6
Notice: Trying to get property 'category_parent' of non-object in /var/www/html/custom/wp-content/themes/cocrework/category.php on line 7
The following code is used.
<?php
$cat_now = get_the_category();
$cat_now = $cat_now[0];
$parent_id = $cat_now->category_parent;
$args = array(
'child_of' => $parent_id,
);
var_dump(wp_list_categories($args));
?>
$cat_now
is empty (no items in the array).