WordPress.org

Ready to get started?Download WordPress

Forums

Adding category name as a class in a custom menu li (1 post)

  1. I.g.C.
    Member
    Posted 1 year ago #

    Hi there :)

    I'm using categories to build up a "portfolio" menu, and planning to give to each category its own style so what I need is to display the category name ad class of li elements of such menu, as it happens for posts.

    I've read the docs about wp_nav_menu wich gives me 2 ways: one is the filter to add a special class only in give conditions. Not usefull to me because I need to have category names in all the elements. Second way: a custom walker, wich seems to be nice but due to the fact that I am a noob in php is too much hard.

    Is there an easier way to add the post_class() (as shown here) as a filter (or somewhat) in the wp_nav_menu()?

    Here is my test site and here is my goal.

    I tried out many other css ways but I realized I need to deal with single li elements. That's why I need to get the category name.

    Thank you for your time.

Topic Closed

This topic has been closed to new replies.

About this Topic