WordPress Sidebar:
list post titles by category

wordpress code, list posts by category, sidebar

Thanks for some helpful hints in the WordPress forums, I managed to tweak the code to list each category with the title of the posts and show them in the sidebar. Here is my solution:

The ??? in the “for” loop has to be larger than the number of categories you have. And you might need to play with the < ul > and < li > tags to fit your nested lists.

Also notice the “for” loop stops before category id 1 ($cat_ct > 1), because I didn’t want to show the “uncategorized” items.

I hope this will help other people searching for the answer like I was.