Please Correct This WordPress (PHP) Code For Showing subcategories on Category page.
Category==>> Sub-Category==>> Posts (Under Sub Category)
What I want to accomplish is:
1. When somebody clicks on Category Name, they should see a list of Sub categories on Category Page.
2. Now when somebody clicks on Sub-Category Name, they should see a list of Titles of Posts filed under that Sub category.
The code which I'm using to accomplish this task is as follows:
----------------------------------------------------------------------
<?php if (is_category()) {
= get_category();
if (get_category_children() != "") {
echo "<ul>";
wp_list_categories('orderby=id&depth=1&show_count= 0&title_li=
&use_desc_for_title=1&child_of='.);
echo "</ul>";
}
}
else{ ?>
<ul>
<?php
;
= get_posts('category=.&numberposts=5&order=desc');
foreach ( as ) : setup_postdata();
?>
<li><a href="<?php the_permalink();?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
<?php }
?> As you can see from above, the IF statement checks whether current category has any child and displays a list of sub categories if it's true.
When IF fails, then the code enters the ELSE loop where it simply prints out the list of all posts filed under that Sub-category ID.
Now the problem is, that the IF loop works fine but when we enter the ELSE loop (That is, when somebody clicks on any Sub category), then nothing is displayed (Even though there are posts filed under that sub-category)
Can somebody help me with this?
Thanks in advance

Bhupinder