Because there is no category option on pages I desided to add post category to main nav. I added the category and added posts on it but it doesn't dsplays the sub category on menu. what should I do to make it work?

Another thing is If I am inside one of the post/page of a category I want to display all the page / post menu on left side bar.

Thanks in advance

1 Answer 1


I had put the following code into sidebar.php to display a list eith sub-categories of "Store" categori and the posts of them. Hope I understand what you need and it will be helpfull. if not can ask more explicite

                // Get categories for parent category store
                // Get ID cat by slug
                $id_store = get_category_id('store');

                $stores = get_categories(array('child_of' => $id_store, 'hide_empty' => 0));
                     <?php foreach ($stores as $categ_list): ?>
                        <li class="cats-<?php echo $categ_list->cat_ID; ?> dropcats">

                                <?php echo $categ_list->cat_name; ?>

                    $args = array(
                        'category' => $categ_list->cat_ID,
                        'numberposts' => -1,
                        'orderby' => 'title',
                        'order' => 'asc'

                    // Get posts for store category

                    $store_posts = get_posts($args);
                    // If there is any posts
                    if (count($store_posts) > 0) {

                            <ul class="markes">
                                <?php foreach ($store_posts as $post) { ?>              
                                    <li class="post-<?php echo $post->ID; ?>">
                                        <a href="<?php echo $post->post_name; ?>" class="marke-<?php echo $post->ID;?>">
                                            <?php echo $post->post_name; ?> 
                                <?php } ?>

            <?php   } 


  • I added a plugin called "Sub Pages widget". it worked for me. Here is the link
    – kamal
    Aug 21, 2011 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.