• Hi,
    I’ve managed to get my categories listed in parent/child order, but I would also like to have an indent for the child categories so that it is easy to distinguish parent and child categories. My list_cats arrangement is as follows:

    <?php list_cats(true, ‘all’, ‘ID’, ‘asc’, ‘index.php’, true, false, true, false, true, true, ”,’0′,”,’RSS’, ”, true) ?>

Viewing 5 replies - 1 through 5 (of 5 total)
  • The indention of lists comes from the CSS not from the template tag. You need to set the UL and LI margins so they will be positioned where you want them to be. In most WordPress Themes, the sidebar list is in a nested list form, which can be really confusing to track and figure out which part of the list belongs to which part you want indented. To help you figure it out, see Styling_Lists_with_CSS and Customizing Your Sidebar.

    Thread Starter ivanm

    (@ivanm)

    I’ve got the CSS part OK, but what I actually need is for WordPress to child categories below parent categories with an indent- e.g.
    < ul >< li >Parent< /li >
    < ul > < li > Child 1 < /li>
    < li > Child 2 < /li>

    < li > Parent 2 < /li >
    < ul > < li > Child 1 < /li>
    < li > Child 2 < /li>

    and so on. I have done the CSS, but I need WordPress to render the code as above. I think it’s in my actual template tag.

    Umm, it already does it by putting the children in a <ul> if you configure it right:

    https://www.viper007bond.com/

    wp_list_cats('sort_column=name&optioncount=1&hide_empty=0&hierarchical=1');

    Thread Starter ivanm

    (@ivanm)

    Cheers, that’s what I was looking for!

    First, I tried to find the original post/ forum that linked me to the answer to my quest, but I can’t find it for the life of me… So, I’m posting here on a discussion that has already tried to answer the problem.

    My problem was the same as the above people here, all suffering from lack of Category Indentation and want the quick fix. I tried in vain to get my category tag wp_list_cats to show the proper Parent/Child relationship in my side-bar for days, but only to stumble across a post that did fix the problem in foul swoop. I wish I could find that post again–it was good?

    I figured that the problem was not in the use of the tag (wp_list_cats) nor the CSS I was using. I went through the ul, li, ul ul li, …. etc and messed with the “wp_list_cats (‘sort_column =name& optioncount=1&….. etc..” but to no avail. Then I went to the root of my problem which seems to have been some broken code in Word-Press itself. And regrettably, I cannot say that it is broken or intentionally left out because I never really looked and compared the two files, however it did show Parent / Child sub-categories in the side-bar when I reapplied (or uploaded) the fixed-template-functions-category.php. It was miraculously fixed. I even went back to my theme folder and CSS and replaced them back to their original code, the Parent / Child indentation was still working!

    So, Like the original post said: You want Parent / Child indentation on your categories, try this first: Upload this file into your /root/ wp-includes / directory and replace the old file called: template-functions-category.php… then you’ll have indentation in your categories! This should also be in the Word Press Codex…. *hint* *hint*

    Get the file:
    https://trac.www.ads-software.com/file/trunk/wp-includes/template-functions-category.php?rev=2396

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Indenting child categories’ is closed to new replies.