Support » Plugins » List all of child categories in dropdown menu

Viewing 4 replies - 1 through 4 (of 4 total)
  • <select name=”event-dropdown” onchange=’document.location.href=this.options[this.selectedIndex].value;’>
    <option value=””><?php echo attribute_escape(__(‘Select Event’)); ?></option>
    $categories= get_categories(‘child_of=10’);
    foreach ($categories as $cat) {
    $option = ‘<option value=”/category/archives/’.$cat->category_nicename.'”>’;
    $option .= $cat->cat_name;
    $option .= ‘ (‘.$cat->category_count.’)’;
    $option .= ‘</option>’;
    echo $option;

    I would use an ordinary menu + suckerfish fix for ie6.

    Then you’ll just do this whereever you have your horizontal menu;

    <li><a href="#" class="<?php if (is_single()) {echo 'selected';};?><?php if (is_category()) {echo 'selected';};?>" onclick=";return false;">Nyheter</a>
    wp_list_categories('orderby=id&title_li='); ?>

    And you will of course need the CSS in order to have the dropdowns working. Something like for example;

    /* menu, main */
    #menu, #menu ul { float:left; list-style:none; line-height:20px; padding:0; margin:0; }
    #menu { float: none; font-size:11px; text-transform:uppercase; background: url(images/menubkg.png) no-repeat; margin-top:25px; padding-left:25px; padding-top:20px; height:34px; }
    #menu li a.selected, #menu li.current_page_item a, #menu li.current_page_parent a, #menu li.current_page_ancestor a { color:#000; border-bottom:2px solid #449dd5; }
    #menu li ul li.current_page_parent a { color: #000; background: url(images/bullet.png) no-repeat 0 5px; color: #000; padding-left:20px; margin-left:5px; } /* style subsub-link */
    #menu li ul li.current_page_parent li.page_item a { background:none; color: #444; padding-left:10px; } /* style for sub-sub-sub -links */
    #menu li ul li.current_page_parent li.page_item a:hover { color: #000; }
    #menu a, a.visited { display:block; color:#666; padding:0; text-decoration:none; }
    #menu a:hover { border-bottom:2px solid #449DD5;}
    #menu ul ul a:hover { border-bottom:0; }
    #menu li { float:left; padding:0; margin-right:15px;}
    #menu li ul { position:absolute; left:-999em; height:auto; width:140px; padding:5px 0 5px 0; margin:0; line-height:1; text-transform:none;}
    #menu li li { padding-right:1px; display:block; }
    #menu li li a { display:block; width:130px; } /* links inside box */
    #menu li ul ul { margin:-20px 0 0 131px; } 
    #menu li ul li ul { position:absolute; margin-left: 70px; background: #000; }
    #menu li:hover ul ul, #menu li:hover ul ul ul, #menu li.sfhover ul ul, #menu li.sfhover ul ul ul { left:-999em; }
    #menu li:hover ul, #menu li li:hover ul, #menu li li li:hover ul, #menu li.sfhover ul, #menu li li.sfhover ul, #menu li li li.sfhover ul { left:auto; background:#fff; border:1px solid #ccc; border-bottom:2px solid #aaa; }
    #menu li:hover a, #menu li.sfhover a { border-bottom:2px solid #449DD5; color: #000; }
    #menu li:hover li a, #menu li.sfhover li a { border-bottom:0; color: #666; padding:5px 0px 5px 10px; line-height:16px;}
    #menu li:hover li a:hover, #menu li.sfhover li a:hover { color: #000; }

    Note that my examples are you picked out from some of my own code so it isn’t quit clean and just doesn’t just do what you ask. For further reference regarding suckerfish dropdowns just search for “suckerfish dropdowns” on Google and you’ll find lots of guides.

    Good luck. 🙂

    Thanks Gulflee

    I have been ages trying to work out just how to create a look up for names referred to in a post.

    For other readers info here, I have created categories for general use in a mimbo based theme site.

    It’s a dog rescue group who have a need to know which dog was referred to in a blog post. (Blogger dealt with that by using labels).

    So I have created a category called AllDogs and hidden that by enabling Advanced Category Excluder plugin. (*NOTE – the parent you hide in this theme needs to be at the top of the category list, eg Aa , otherwise if it is halfway down, then the top categories get hidden without choice.)

    I have then created, and new posters will be able to create more, sub categories of the hidden AllDogs category.

    Then using the code provided by Gulflee above and using the appropriate category_ID number and changing “Select Event” to read “Select Name” I have a drop down list of just Dogs names and the parent & children do not appear in the “Browse Categories” feature of the mimbo theme.

    Long winded post but I hope of some use to somebody.

    Could you please post the code that would display all posts from all categories in a dropdown box?


Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘List all of child categories in dropdown menu’ is closed to new replies.