WordPress.org

Ready to get started?Download WordPress

Forums

list_cats Display in Nested List (19 posts)

  1. rndpkt
    Member
    Posted 9 years ago #

    Maybe I'm just missing something reading through the code, but is there a way to cause the list_cats function to output the list of categories in a nested, list based on their parent-child relationships? I tried changing some of the function parameters with no success and I can't find anything in the forums about it. Anyone? Thanks in advance!

  2. Kafkaesqui

    Posted 9 years ago #

    The default _is_ to list categories in parent-child hierarchical nested list (there is a 'hierarchical' parameter in list_cats() and wp_list_cats(), but either it or the 'list' parameter must be specifically set to false/off.

    If you're not seeing this, it's possible the menu/sidebar ul and li tag properties in your stylesheet are overriding how it's displayed.

  3. theboywonder
    Member
    Posted 9 years ago #

  4. theboywonder
    Member
    Posted 9 years ago #

    Woh, you can't edit posts anymore :/

    What are the arguments at current for your list_cats function?

  5. indi
    Member
    Posted 9 years ago #

    wp_list_cats isn't displaying a hierarchy for me (on 1.5). It's not the CSS because I've viewed the source and its not producing the HTML for a nested list at all.

    I've also replicated the error on multiple themes.

    Any clues?

  6. rndpkt
    Member
    Posted 9 years ago #

    I'm using the base stuff from the 'nolimits' theme. The PHP call is:

    <?php list_cats(0, '', 'name', 'ASC', '/', true, 0, 1); ?>

    My HTML output is:

    <h2>Categories:</h2>

    Teas, Wines should be sub-lists under Beverages.

  7. rndpkt
    Member
    Posted 9 years ago #

    Doh!!


    <h2>Categories:</h2>

  8. rndpkt
    Member
    Posted 9 years ago #

    Hmmmm....

    <h2>Categories:</h2>

  9. rndpkt
    Member
    Posted 9 years ago #

    <h2> Categories:</h2>

  10. rndpkt
    Member
    Posted 9 years ago #

    {h2}Categories:{/h2}
    {ul}
    {li}{a href="http://www.devrandom.org/?cat=2" title="View all posts filed under Technology">Technology{/a> (2){/li}
    {li}{a href="http://www.devrandom.org/?cat=8" title="View all posts filed under Beverages">Beverages{/a> (1){/li}
    {li}{a href="http://www.devrandom.org/?cat=9" title="View all posts filed under Wines">Wines{/a> (1){/li}
    {li}{a href="http://www.devrandom.org/?cat=10" title="View all posts filed under Teas">Teas{/a> (1){/li}
    {/ul}

  11. rndpkt
    Member
    Posted 9 years ago #

    That's what my code snippet prints out. Sorry for the multi-paste erors.

  12. Root
    Member
    Posted 9 years ago #

    Presumably we arent going to get nested lists with an h2 tag in there ?

  13. chuckblue
    Member
    Posted 9 years ago #

    I have the same problem under 1.5

    sub-categories listing as separate categories.

  14. timothyb
    Member
    Posted 9 years ago #

    ME too!!! is this something as a bug under 1.5?

    I have <?php wp_list_cats("sort_column=name&showempty=1&optioncount=1"); ?> and it won't do anything but list all my categories and subcategories in non-alphabetical order. =(

  15. chuckblue
    Member
    Posted 9 years ago #

    my wp_list_cats has no options. I'm using the Aesthetic theme. I emailed the theme maker, but no response from 3 days ago, must be busy. Or its a 1.5 thing.

  16. chuckblue
    Member
    Posted 9 years ago #

    hrm, edit is off.

    I did check a 1.2.2 blog I use, and it has no options either. Yet it displays the subs under the parent category.

    So it must be a change in 1.5

  17. indi
    Member
    Posted 9 years ago #

    Ryan just posted an updated template-functions-categories.php that fixed my problem:

    Patched File

    Original Thread

  18. chuckblue
    Member
    Posted 9 years ago #

    my site is now working correctly.

    Thanks !

  19. chuckblue
    Member
    Posted 9 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.