• Resolved hbalagh

    (@hbalagh)


    I am using the following code just to list the child cats problem is it says categories above the listing and I would rather take that out or alter the name of it to say something like topics

    <?php
    
      $ID = $wp_query->posts[0]->ID;
      $postcat = get_the_category($ID);
      $cat = $postcat[0]->cat_ID;
      $parent = get_category ($cat);
        if ($parent->parent) {
          wp_list_categories ('child_of=' . $parent->parent);
          } else {
          wp_list_categories ('child_of=' . $cat);
        }
    
    ?>
Viewing 1 replies (of 1 total)
  • Thread Starter hbalagh

    (@hbalagh)

    got the solution

    <?php
      $ID = $wp_query->posts[0]->ID;
      $postcat = get_the_category($ID);
      $cat = $postcat[0]->cat_ID;
      $parent = get_category ($cat);
        if ($parent->parent) {
          wp_list_categories ('title_li='.__( 'Blogs' ).'&child_of=' . $parent->parent);
          } else {
          wp_list_categories ('title_li='.__( 'Blogs' ).'&child_of=' . $cat);
        }
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Listing Child Cats’ is closed to new replies.