Forums

[resolved] Listing Child Cats (2 posts)

  1. hbalagh
    Member
    Posted 2 years ago #

    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);
        }
    
    ?>
  2. hbalagh
    Member
    Posted 2 years ago #

    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);
        }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.