WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to add sub-categories? (10 posts)

  1. break_r
    Member
    Posted 8 years ago #

    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.

  2. break_r
    Member
    Posted 8 years ago #

    Wher bar1 and bar 2 above would be indented as sub-categories =P

  3. Michael Bishop

    Posted 8 years ago #

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

  4. break_r
    Member
    Posted 8 years ago #

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

  5. Chris_K
    Member
    Posted 8 years ago #

    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.

  6. break_r
    Member
    Posted 8 years ago #

    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.

  7. break_r
    Member
    Posted 8 years ago #

    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

  8. break_r
    Member
    Posted 8 years ago #

    Again in sidebar.php, there's:

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

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

  • Chris_K
    Member
    Posted 8 years ago #

    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.

  • break_r
    Member
    Posted 8 years ago #

    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.

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags

    No tags yet.