Forum Replies Created

Viewing 1 replies (of 1 total)
  • Hi,

    Don’t know whether you still need help in this area, but I have the same requirement and have had no luck in finding a built in WordPress function to do it. I have therefore knocked the code below together, feel free to use it.

    It builds an Unordered List of top level categories and then a nested UL of the appropriate posts. It adds links to both the category list page and the posts themselves.

    If you need any help with it or if it doesn’t quite do everything you need, let me know and I could add to it for you.

    To make it look good, you will have to do the appropriate CSS.

    <div id="sidebar">
        <ul>
            <?php
                $categories=get_categories();
                foreach($categories as $category) {
                    echo '<li><a href="'.get_category_link($category->cat_ID).'"><h2>'.$category->category_nicename."</h2></a></li><ul>";
                    $category_posts=get_posts('category='.$category->cat_ID);
                    foreach($category_posts as $post) {
                        echo '<li><a href="'.$post->guid.'">'.$post->post_title.'</a></li>';
                    };
                    echo "</ul>";
                }; ?>
        </ul>
    </div>
Viewing 1 replies (of 1 total)