WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] How to add sub-categories?

[Resolved] How to add sub-categories?

  • Hi,

    Under “Categories” on the sidebar, I’d like to have something like this:

    Foo
    bar1
    bar2
    Woot
    one
    two

    Is this possible? Under Manage->Categories I specify the parent for a new category but it doesn’t place the child category in a manner above.

    Regards.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Wher bar1 and bar 2 above would be indented as sub-categories =P

    Depending on your theme, you will want to look at these two template tags
    Template Tags/list_cats
    Template Tags/wp_list_cats

    I was hoping there was something in the WordPress UI but I’ll dig around the tags. Thx!

    Break_r – just to be sure… you’ve noticed that in the category manager, you can specify the “parent category” for a cat, right? Once that’s done, some themes will handle displaying them hierarchicly (pardon my spelling). If yours doesn’t, then you’ll need to look at the links miklb provided and edit your theme a wee bit.

    For instance:
    <?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=1'); ?>
    will do the job. Notice the hierarchical=1 part of that.

    thx. I was actually just playing with that line of code.

    In sidebar.php, u’ll need both hierarchical and children for the default theme in 2.0

    For example:
    wp_list_cats(‘sort_column=name&optioncount=1&hierarchical=1&children=1’);

    Regards.

    nope. my bad. just hierarchical alone appears to work.

    What if I’m going about this wrong. Why not have multiple “Categories” sections.

    Ie.

    Category1
    >foo1
    >bar1

    Category2
    >foo2
    >bar2

    Again in sidebar.php, there’s:

  • <h2>Categories</h2>
      <?php wp_list_cats(‘sort_column=name&optioncount=1&hierarchical=0’); ?>
  • So I just cut’n paste another one below and rename it:

  • <h2>Categories2</h2>
      <?php wp_list_cats(‘sort_column=name&optioncount=1&hierarchical=0’); ?>
  • It shows the second category but it mirrors all the subcategories of the first one. Sorry, this is my first encounter with php =P

I guess I’m not following. I’m assuming that “category1” is a category and then when you create “foo1” category you specified “category1” as its parent. Right?

In your above example, you need to change hierarchical to = 1, not 0.

Here’s my test page to see what I’m trying to do:

http://www.conceptualinertia.net

Under “Categories2” I’d like a different list.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Resolved] How to add sub-categories?’ is closed to new replies.