• Resolved ajithperuva

    (@ajithperuva)


    Hi,
    I would like to create a tutorial website using word press. How can we display subcategory with all its post title in a page. Consider,I have main navigation(Category) as Lessons and it has different subcategories like Chapter1,Chapter2,Chapter3 and so on….Here I need to display all subcategories under Lessons with titles of its own posts.Already I tried with
    wp_list_categories('child_of=10')
    But, by using the same how can we retrieve each post title..
    Sorry for my bad English.Thank you

Viewing 1 replies (of 1 total)
  • I could be completely wrong about what you are trying to achieve, but maybe this will help. You should use get_categories so that you can retrieve an array of sub-categories.

    $children_cats = get_categories('child_of=10&orderby=ID&order=ASC');

    The order attributes make it so that you will get a list of the categories ordered by the sequence in which you created them.

    With the new array, use it to make new loops:

    foreach($children_cats as $cat){
    
    wp_list_categories('title_li=&include='.$cat); // Show only the current category name first
    
    $sub_query = new WP_Query('category__in='.$cat); // Add any other arguments as needed
    echo('<ul>');
    while ($sub_query->have_posts()) : $sub_query->the_post(); ?>
    
    <li id="post-<?php the_ID(); ?>"><a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    
    <?php endwhile;
    echo('</ul>
    ');
    $sub_query = null;
    
    } // End of foreach loop

    The loop query uses category__in so that ONLY that category’s posts are listed, rather than that and it’s children (which would then duplicate posts in your listing).

    Good luck

    J

Viewing 1 replies (of 1 total)
  • The topic ‘WordPress 3.0 Subcategory listing with Post Title only’ is closed to new replies.