• hey guys,

    here’s my problem..
    i have added 5 parent categories with like 5subcategories under each
    example
    -Products
    –TV
    –RADIO
    –GAMES
    etc

    what i want is to get the level 2 categories to be displayed under the category listing page. it’s kinda easy, since i have done this a few weeks ago, but anytime i click on a subcategory, the list gets empty, since it tries to pull out the subcategories of the subcategories again.

    so, here’s what i want
    i want to get a static level 2 category list to be displayed only. so, when i click products, i want to see the subcategories only, if i click a subcategory, i want to get the same list as before.

    any help appreciated!

    kind regards,
    zerovic

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter zerovic

    (@zerovic)

    ok well, i couldn’t sleep last night, so i have played around with the codes ??
    here’s the solution!

    <h4>Categories</h4>
    <ul class=’xoxo blogroll’>

    • <?php
      $parentCatList = get_category_parents($cat,false,’,’);
      $parentCatListArray = split(“,”,$parentCatList);
      $topParentName = $parentCatListArray[0];
      $id = get_cat_id($topParentName);
      wp_list_cats(‘sort_column=id&optioncount=0&use_desc_for_title=0&child_of=’ . $id);
      ?>

    kind ragards,
    zerovic

    zerovic you’re great!!! solve my issue about show posts in child cats calling from parent cat ID.
    if any one looking that I let the code I use.

    <?php
    $temp = $wp_query;
    $wp_query = null;
    $wp_query = new WP_Query();
    $parentCatList = get_category_parents($cat,false,',');
    $parentCatListArray = split(",",$parentCatList);
    $topParentName = $parentCatListArray[0];
    $id = get_cat_id($topParentName);
    $wp_query->query('cat='.$id.'&order=ASC');
    ?>
    
    <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    
    //Stuff
    
    <?php endwhile; ?>
    
    <?php $wp_query = null; $wp_query = $temp;?>

    That′s it, beautiful!
    Cya

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘List Subcategories of Parent Category’ is closed to new replies.