WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Indenting Subcategories (15 posts)

  1. skakels
    Member
    Posted 5 years ago #

    Hi All,

    I am using WP 2.5.1 with the Whitespace 3-column theme. My problem is that my left side bar, which hosts my categories, is showing all my categories, and sub categories, as though they are on the same parent tier of the category hierarchical structure.

    This is the below code from the l_sidebar.php file to output all categories, and subcategories, to my page:
    <?php wp_list_categories('sort_column=name&title_li='); ?>

    For example, I have a partent category named "Active Directory" with a child subcategory named "Scripting".

    Currently the two related categories are being outputted like this:
    Quote:

    Active Directory
    Scripting

    My end goal is to denote that the "Scripting" subcategory is a child subcategory rather than a parent category. Ideally, I would like this done either by an indent(space) or perhaps a dash. Can anyone offer a solution, tip, or suggestion? I have been trying to figure this out for quite some time.

    Additionally, how hard would it be to show the count of postings at the right of each category name?

    Active Directory
    _Scripting <-- underscore denotes a space

    or

    Active Directory
    -Scripting

    Thank you all in advance for your help.

  2. syrupcore
    Member
    Posted 5 years ago #

    Can you post a link to your site or paste the code the browser is generating for the nav?

  3. skakels
    Member
    Posted 5 years ago #

    Hi syrupcore,

    Below is the URL to my site. I have made a change that returns the sum of the articles within each category, but I still cannot get the indenting to work correctly.

    Here is the code to return the amount of posts from each article:
    <?php wp_list_categories('show_count=1&title_li='); ?>

    Site:
    http://shortlink123.bounceme.net

  4. Chris_K
    Member
    Posted 5 years ago #

    Start with a look at the documentation for wp_list_categories: http://codex.wordpress.org/Template_Tags/wp_list_categories

    (look for the "hierarchical" parm, I think that's the one you're after.)

  5. skakels
    Member
    Posted 5 years ago #

    Hi HandySolo,

    I have been looking at the exact article you identified, but I cannot seem to get the code to work correctly.

    I am new to php and css, so my experience with witting or modifying code is still limited.

    If anyone can show me the code I will need, or code very close to what I am looking for, I would be extremely appreciative. Thank you all for your help thus far! :)

  6. Chris_K
    Member
    Posted 5 years ago #

    Try <?php wp_list_categories('hierarchical=1&sort_column=name&title_li='); ?>

    hierarchical is listed as defaulting to on, but what the heck, won't hurt to explicitly set it I reckon.

  7. skakels
    Member
    Posted 5 years ago #

    Handy,

    I tried the code you suggested, but it returned the same problem I had stated in my first post. What could be trumping an explicit statement?

    Site:
    http://shortlink123.bounceme.net

  8. syrupcore
    Member
    Posted 5 years ago #

    your template code is fine. just need to update the CSS. the subitems are in a ul classed "children". in your css, add something like:

    ul.children{margin-left: 10px;}

    and you should be good to go. then go get firebug. ;)

  9. skakels
    Member
    Posted 5 years ago #

    You make that sound so easy about adding it into the CSS. Sadly, at my skill set, I am not 100% sure what you mean.

    How can I add that string you gave into my CSS so it will work with?
    <?php wp_list_categories('hierarchical=1&sort_column=name&title_li=');

  10. Chris_K
    Member
    Posted 5 years ago #

    look at your theme's stylesheet. That's where you want to make the change.

    Odds are you don't even need the change I suggested earlier (thanks syrupcore!) but just need to tweak the CSS a bit.

  11. syrupcore
    Member
    Posted 5 years ago #

    Hiya.

    In the admin, go to: Design>Theme Editor

    On the right side, click on "styles.css" likely at the bottom of the list.

    paste ul.children{margin-left: 10px;} at the bottom of the file.

    click "update file".

    All set. I think.

  12. skakels
    Member
    Posted 5 years ago #

    syrupcore,

    I tried your suggestion, but my categories are still displaying the same. Any thoughts?

  13. syrupcore
    Member
    Posted 5 years ago #

    sorry about that. Your css declaration was getting pwned by a sith lord. Change the last line to:

    #l_sidebar ul.children{margin-left: 10px;}

  14. skakels
    Member
    Posted 5 years ago #

    awesome! thank you for the help. VERY much appreciated.

  15. skakels
    Member
    Posted 5 years ago #

    syrupcore,

    Since have helped me so much with this issue, I have a question off topic.

    If you look at my page, you will see a search bar on the right side of my navigation bar.

    I have been trying to get the search box to center of the middle of the blue line, but I cannot figure it out. Could you offer a quick solution for this? Thanks again!!

    http://shortlink123.bounceme.net

Topic Closed

This topic has been closed to new replies.

About this Topic