Solved thanks to some altered code from a previous post:
<?php $this_category = get_category($cat); ?>
<!-- If category is parent, list it -->
<?php if ($this_category->category_parent == 0) { ?>
<?php #echo get_category_link($cat); ?>
<?php #echo $this_category->cat_name; ?>
<?php #echo $this_category->cat_name; ?>
<?php $this_category->category_parent = $cat; ?>
<?php } else { ?>
<!-- If category is not parent, list parent category -->
<?php $parent_category = get_category($this_category->category_parent); ?>
<?php #echo get_category_link($parent_category->cat_ID); ?>
<?php #echo $parent_category->cat_name; ?>
<?php #echo $parent_category->cat_name; ?>
<?php $getParentCatId = $parent_category->cat_ID; ?>
<?php #echo $getParentCatId; ?>
<?php } ?>
I then pass the id where I need it:
if ( is_category() ) {
#pass the id from above to here to create the correct menu
$parent = $getParentCatId;
$categories = get_categories('include='.get_query_var('cat'));
if ( $categories[0]->category_parent == $parent ) {
#echo 'category ' . $categories[0]->name . ' is a child of category ' . $parent;
query_posts('cat='.$cat.'&showposts=9999');
?>
<ul>
<?php
while (have_posts()) : the_post();
?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php
endwhile;
?>
</ul>
<?php
}
}
hope it may help someone else…