Title: Sub Categories Links
Last modified: August 19, 2016

---

# Sub Categories Links

 *  Resolved [gward1](https://wordpress.org/support/users/gward1/)
 * (@gward1)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/sub-categories-links/)
 * Hello,
 * The website I’m working on is going to have hundreds if not thousands of categories
   and sub categories so I need to have them organized well.
 * Is there a plugin that will list the sub categories on each category page? I 
   would prefer this because I’m using the extended categories plugin which lists
   select categories (top level only) in a widget. Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/sub-categories-links/#post-1380691)
 * For use in category template to list child categories– if no child categories
   list whatever
 *     ```
       <?php
       if ( is_category() ) {
         $cat = get_query_var('cat');
         $child_cats = get_categories('child_of='.$cat);
         if ($child_cats) {
           $args = array(
             'title_li' => '',
             'echo' => 1,
             'child_of' => $cat
           );
           wp_list_categories($args);
         } else {
           //do whatever if no child cats like do a post loop
         }
       }
       ?>
       ```
   
 *  Thread Starter [gward1](https://wordpress.org/support/users/gward1/)
 * (@gward1)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/sub-categories-links/#post-1380978)
 * I found this code on a different website and it seems to be doing what I want
   with a few exceptions.
 * [code]
    <?php
 * // outputs subcategories in same way, if there are any (if you're browsing a 
   parental category)
 * $has_children = (bool)(get_category_children(intval(get_query_var('cat'))));
 * if (is_category() AND $has_children) {
    wp_list_categories('title_li=<h2>Alphabetical
   Listing of Artists</h2>&child_of=' . intval(get_query_var('cat'))); }
 * ?>
    [/code]
 * However it puts a bullet next to the title_li, which I don’t want because it 
   looks weird. You can see what I mean on this page: [http://www.songlyricsx.com/lyrics/a/](http://www.songlyricsx.com/lyrics/a/).
 * Here’s the code for the posting part which is displayed above the current subcategories:
 * [code]
    <div class="middle">
 *  <?php if (have_posts()) : ?>
 *  <?php while (have_posts()) : the_post(); ?>
 *  <div id="post-<?php the_ID(); ?>">
    <h2>" rel="bookmark" title="Permanent Link
   to <?php the_title(); ?>"><?php the_title(); ?>
   </h2>
    <p><small><?php the_time('
   F jS, Y') ?> <?php the_author() ?></small> Posted in <?php the_category(', ')?
   > <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?
   > <?php edit_post_link('Edit', '', ' | '); ?> <?php if(function_exists('the_views')){
   the_views(); } ?></p>
 *  <div class="entry">
    <?php the_content('Read the rest of this entry »'); ?> 
   </div>
 *  <!-- AddThis Bookmark Post Button BEGIN -->
    <?php echo "<div class=\"addthis\"
   ><img src=\"http://s9.addthis.com/button1-bm.gif\" width=\"125\" height=\"16\"
   border=\"0\" alt=\"AddThis Social Bookmark Button\" />
   </div>"; ?>
    <!-- AddThis
   Bookmark Post Button END --> [/code]
 * How do I modify this so that if it’s a parent category no post is shown and if
   it’s a child category it shows the posts? Thanks!
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/sub-categories-links/#post-1380999)
 * Please paste ALL the code from that template file into a pastebin such as [wordpress.pastebin.com](http://wordpress.pastebin.com),
   and report the link back here. Maybe someone can spot your problem. Thanks.
 *  Thread Starter [gward1](https://wordpress.org/support/users/gward1/)
 * (@gward1)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/sub-categories-links/#post-1381019)
 * Hello,
 * I figured it out by incorporating your code. The last thing is what do I need
   to change to make it so that if there are 100 subcategories it will go to another
   page? Is this possible? The code can be found here for category.php: [http://wordpress.pastebin.com/m97fa786](http://wordpress.pastebin.com/m97fa786)
 * Thanks.
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/sub-categories-links/#post-1381020)
 * I’ve not found a way to paginate wp_list_categories.
 *  Thread Starter [gward1](https://wordpress.org/support/users/gward1/)
 * (@gward1)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/sub-categories-links/#post-1381023)
 * Bummer, thanks for the help though.
 *  Thread Starter [gward1](https://wordpress.org/support/users/gward1/)
 * (@gward1)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/sub-categories-links/#post-1381040)
 * Found a possible solution here: [http://wordpress.org/support/topic/336324?replies=16](http://wordpress.org/support/topic/336324?replies=16)

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Sub Categories Links’ is closed to new replies.

 * 7 replies
 * 2 participants
 * Last reply from: [gward1](https://wordpress.org/support/users/gward1/)
 * Last activity: [16 years, 3 months ago](https://wordpress.org/support/topic/sub-categories-links/#post-1381040)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
