The MU forums have moved to WordPress.org

wp_list_categories() not adding class? (3 posts)

  1. JMF
    Member
    Posted 17 years ago #

    I just noticed that my calls to wp_list_categories() in my menu bars isn't working as expected.

    The WordPress documentation says that it should automatically add class='page_item' or class='current_page_item' to list elements, but I'm getting nothing. I hope I'm not missing something stupid, but I've spent a while poking at it, and rummaging around in the WP supprot forums.

    Could somebody check this out for me? Here's my menubar code:

    <ul id="menu">
    <li class="<?php echo($sMenuHome); ?>"><a href="<?php echo get_settings('home'); ?>/"><?php _e('Home', 'gluedideas_subtle'); ?></a></li>
    
    <?php if(count(get_all_category_ids())<3) {
    } else { wp_list_categories('sort_column=id&depth=1&title_li=0&exclude=1');} ?>
    
    <?php wp_list_pages('sort_column=menu_order&depth=1&title_li=0'); ?>
    </ul>

    And here's what it outputs (abbreviated):

    <ul id="menu">
    <li class="current_page_item"><a href="*">Home</a></li>
    <li><a href="*" title="A category for class logs.">Class 1</a>
    </li>
    <li><a href="*" title="Another category for class logs.">Class 2</a>
    </li>
    <li><a href="*" title="A log for a third class.">Class 3</a>
    </li>
    <li><a href="*" title="View all posts filed under Events">Events</a>
    </li>
    <li class="page_item"><a href="*" title="About">About</a></li>
    <li class="page_item"><a href="*" title="Resources">Resources</a></li>
    <li class="page_item"><a href="*" title="Calendar">Calendar</a></li>
    </ul>

    As you can see, the items generated by wp_list_categories() are plain old li's with no class added at all. I've tried this with several themes, and also a raw

    <?php echo wp_list_categories('sort_column=id&depth=1&title_li=&exclude=1'); ?>

    at the top of a blank page with the same results.

    Am I missing something?

  2. JMF
    Member
    Posted 17 years ago #

    Oof. I just upgraded to 1.2.3, if that makes a difference. I'm doubting it's a bug, though...

  3. JMF
    Member
    Posted 17 years ago #

    Sorry, nevermind.

    I guess I was expecting things to line up, ie. wp_list_pages() returns either a class 'page_item' or 'current_page_item'; digging around in classes.php, I realized that wp_list_categories returns either no class or 'current-cat'.

    I was seeing 'current-cat' in places, and wondering why it wasn't 'current_page_item.' I guess now, I know. :P

About this Topic