WordPress.org

Ready to get started?Download WordPress

Forums

remove classes from nav_menu items (5 posts)

  1. kyleiwaniec
    Member
    Posted 3 years ago #

    Hi,

    I am using the nav_menu walker class for my drop-down menu. I've designed it so it doesn't need to use any classes or ids, except those specified by the user when they create their menu. How can I remove the extraneous class names and ids from my menu? (they don't actually do any harm, but it's ugly markup).

    I thought I would extend the Walker class and remove the parts of the function that write the classes, but I don't know how. My problem is I need to keep the user specified classes.

    Here is a function that has the class stuff in it. Can someone help me remove the wordpress generated classes and ids?

    [Code moderated as per the Forum Rules. Please use the pastebin]

  2. Jeremy Pry
    Member
    Posted 3 years ago #

    Since your code was removed by a moderator, please post your code to a pastebin, and share the link here. It would also be helpful to give a pure HTML example of what you're currently getting compared to the end result you want to achieve.

  3. kyleiwaniec
    Member
    Posted 3 years ago #

  4. mmson
    Member
    Posted 3 years ago #

    Your nav html have different color for each navigation tab?

    You use the WP-admin-> Appearance->Menus to create your menu?

    If yes, I remember there is a CSS CLASSES for every menu, you could go to WP-admin-> Appearance->Menus ,
    notice there is a screen Options top right?
    Click in check the CSS CLASSES,
    then you could have a input box for every menu drop down element for "CSS CLASSES (OPTIONAL)", then you could add the color class for each menu.
    Such as class purple for About us
    Hope it helps.

  5. kyleiwaniec
    Member
    Posted 3 years ago #

    what you're describing is exactly what I'm doing. And my colors come up as one of the classes in the items.

    I want to remove the other generated classes.
    ie: menu-item menu-item-type-post_type menu-item-object-page.

Topic Closed

This topic has been closed to new replies.

About this Topic