I have searched the forums and the plugins for hours without finding how I can achieve this. What I want to do is to have a sidebar menu that is a list of all the posts or pages in the category of the currently displayed post or page. I would also like to show the category titles for the other categories.
Something like this:
OtherCat1
OtherCat2
ThisCat
--Item
--Item
--Item
OtherCat3
etc.
I have come to WordPress from Joomla and this was easy to do in Joomla. So, it should be easy in WordPress. Is there a plugin that does this? If not how could I do it?
Ready for use! : )
function showcats() {
$cats = get_categories('hierarchical=1');
print '<ul class="catslist">';
foreach($cats as $cat) {
print '<li>';
print '<a href="'.get_category_link($cat->term_id).'">'.$cat->cat_name.'</a>';
if(in_category($cat->term_id, $post)) {
$psts = get_posts("numberposts=10&cat=".$cat->term_id);
if(count($psts)) {
print '<ul class="postslist">';
foreach($psts as $pst) print '<li><a href="'.get_permalink($pst->ID).'">'.$pst->post_title.'</a></li>';
print '</ul>';
}
}
print '</li>';
}
print '</ul>';
}
Thanx caugb, should be easy to build this code into a Widget.