Let’s suppose you are talking about posts (since Pages don’t have categories). What is it exactly that you expect and is not happening?
When you make a conditional statement based on a cat’s ID# – it doesn’t matter if it is a category or subcategory. Subcategories also have their own ID#.
Hi,
Yeah, I meant posts, not pages. Actually I have a menu in my sidebar. One of my menu has sub-menus that represent sub-categories of a specified category (Category_Name=Essays, Category_ID=3) I want that this menu remain expanded while user are viewing each of sub-categories of category 3. Here is my code:
<ul>
<li><a href="<?php bloginfo('url')?>">Home</a></li>
<li><a href="<?php bloginfo('url')?>/essays">Essays</a></li>
<?php if (is_page('essays') || is_category(3)):?>
<ol id="submenu">
<?php wp_list_categories('hide_empty=0&child_of=3&title_li=')?>
</ol>
<?php endif?>
<li><a href="<?php bloginfo('url')?>/books">Books</a></li>
</ul>
As you see I use is_category. If user open category 5 that is actually is a sub-category of category 3 this condiciton (is_category(3)) is false. I need a function like (is_subcategoryof(3)) that check whether a category is child of a specied category or not.