Quickly add a Category DropDown to Thematic 0.9

Cristian Antohe
Last Updated: 19/10/21

With the launch of Thematic 0.9 we now have out of the box drop-down menus to work with. This is one of the many features added to 0.9 that was requested by the community. However sometimes one might want to replace the default Thematic menu with a menu composed with the categories and sub-categories of your WordPress installation.

Although I’ve done in the past a similar tutorial that one isn’t working anymore with the latest Thematic version so here is a quick and easy way to add a Category DropDown.

First create a Child Theme.
Second create and then open the functions.php file that should be found in your new ChildTheme.
Third add this code to the functions.php file:

[sourcecode language=”php”]

#Add a drop down category menu
function childtheme_category_menu() { ?>
<div id=”category-menu” class=”menu”>
<ul id=”category-nav” class=”sf-menu”>
<?php wp_list_categories(‘title_li=’); ?>
</ul>
</div>
<?php }
add_action(‘wp_page_menu’,’childtheme_category_menu’);

[/sourcecode]

Save and test. You should now have a drop-down from your categories!

15 thoughts on “Quickly add a Category DropDown to Thematic 0.9

    You welcome! 🙂

    Reply

    hi cristi thanx a lot
    but can u help me to place page menu just at start of page?

    Reply

    Replace

    add_action(‘wp_page_menu’,’childtheme_category_menu’);

    with

    add_action(‘thematic_aboveheader’,’childtheme_category_menu’);

    That should put the menu on top of your theme. Note you’ll still have the default menu available.

    Reply

    Perhaps more useful, a function to put the categories right under the regular menu.

    Replace the line with:

    add_action('thematic_belowheader','childtheme_category_menu');

    […] e proviamolo. Articolo scritto da Cristi e pubblicato su CoszmosLabs. Tradotto con il consenso dell’ autore. […]

    Reply

    Great…

    Do I need some additional/extra CSS-ing to make sure it is displayed vertically/dropdown?
    ‘Cause now I’m getting the categories just show horizontally…

    Thanks in advance…

    Regards.

    Reply

    You need to make sure that you have subcategories defined, and that those subcategories have actual articles in them. This code only displays used categories, so if you just added a new subcategory it won’t show up in the dropdown until you associate an article with it.

    Reply

    Thanks for the reply, Mike.

    But I think I was expecting something more/else…

    What I want is a label ‘Categories’ and right beneath that the dropdownbox with categories.
    I can simulate this my creating a ‘dummy’ category called ‘Categories’ and make that the parent of all the other categories…

    I’m wondering whether this is possible without a dummy category.

    Reply

    I’m not a PHP whiz, but I do know a lot about CSS. If you create a parent list for the list that the PHP generates, and then you apply the proper CSS styling to it as shown here http://htmldog.com/articles/suckerfish/dropdowns/ you should be able to get that to work, albeit without the flashy javascript animation and without support for IE6.

    I’m sure there is a better way, but that’s one possibility.

    dumb question…how do we do the same thing for the page list (top menu?). i’d like to do the same as on your commune theme.

    Reply

    I know this is an old thread, but in the hopes that someone still reads it… 🙂 can you tell me how I would exclude the “Uncategorized” tag from showing up on the menu? I tried just adding excluded=1 right in the below code before the title_li… but that just makes the formatting funky, and it adds uncategorized as a sub menu. help! I’m a total newbie to php and css and all this fun stuff!

    Reply

    Hi Kara,

    Could you post this on the cozmoslabs forums here: link.

    This way more people will benefit from the resolve!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.