when you are in a category...
show the subcategories in the sidebar.
Is it possible?
I tried this code and did not work, nothing appears in the sidebar.
<?php
if(is_category()) { // are we on a category or archive page
$current_category = get_query_var('cat'); // the current category id
$category= get_categories( 'include='.$current_category );
// if the parent category ID in the top navigation is the parent of the current category
if($category[0]->category_parent == 3){
$child_categories= get_categories( 'child_of='.$current_category );
if(!empty($child_categories)){
foreach ( $child_categories as $child_cat ) {
$categories[] = $child_cat->cat_ID;
}
$sub_children = implode(',', $categories);
echo '<ul>';
wp_list_categories('include='.$sub_children);
echo '</ul>';
}
}
}
?>
change the ID (3) to your main menu option ID with all the child categories.
$category[0]->category_parent == 3
i'm, using this code..
I acess the top Menu e when i click in one category ( have other subs ) nothing show in my left sidebar
screen: http://img827.imageshack.us/img827/1816/categoriesz.png