Thursday, May 14, 2009

Create horizontal categories menu in WordPress without CSS

To create a horizontal categories menu separated by ' | ' in WordPress, use this code.
echo str_replace('<br />',' | ',


  1. After two hours of searching on the web for a simple menu that does exactly what you've described...Thank you, thank you. I knew it had to be simple, and I don't need the CSS.

  2. just another designeJanuary 16, 2011 at 8:31 PM

    Wow, excellent information! I cannot thank you enough for posting this. This gave me exactly what I needed, now if I could just figure out how to exclude the "Uncatagorized" catagory from showing in the menu. Anyone have any tips?

  3. It is easy to exclude any category. Just add `exclude` to wp_list_categories(). For example, if you want to exclude category with id=2,


    To find the category id,
    1. go to Posts > Categories.
    2. Hover to any category name, and look at your browser status bar. Look for something like `...&tag_ID=2...`. In this case, the category id is 2.

  4. Thanks a million for this =)

  5. I'd love to add some heirarchy to this script. any suggestions?