• Hello, I found a great tutorial about displaying pages and child pages in a very nice dropline, but I need the same functionality for categories instead.

    The original code:

    <ul id="nav">
    <?php wp_list_pages('title_li=&depth=1'); ?>
    
    <?php if($post->post_parent)
    $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else
    $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
    if ($children) { ?>
    <ul id="subnav">
    <?php echo $children; ?>
    
    <?php } else { ?>
    <?php } ?>

    Is there any way to change things around to display categories? I understand I need to use wp_list_categories instead, but I’m guessing the $post variable will be different for categories?

    Would appreciate any help. Thanks in advance!

    Justine

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Justyna Ratajczak

    (@jusi)

    Shameless bump. Anyone able to help?

    I also noticed I didn’t close the ul tags. So the code should be:

    <ul id="nav">
    <?php wp_list_pages('title_li=&depth=1'); ?>
    <./ul>
    
    <?php if($post->post_parent)
    $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else
    $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
    if ($children) { ?>
    
    <ul id="subnav">
    <?php echo $children; ?>
    <./ul>
    
    <?php } else { ?>
    <?php } ?>

    Edit: Please ignore the dots in closing tags. Couldn’t make the preview here work without them.

    Thread Starter Justyna Ratajczak

    (@jusi)

    Still looking for a solution.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Displaying categories in two-level dropline’ is closed to new replies.