Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • This certainly is a way to do this, though would force me to add all items i want to use this for manually in the functions.php . I would rather have a way for the Nav_Dynamic_Walker to use the (standard) optional CSS classes that Wordpress provides. This will be a good fallback method if i cannot though. Commented Nov 4, 2016 at 16:25
  • No, you can have an array of the classes you want to add and loop through before returns $classes Commented Nov 4, 2016 at 16:30
  • The only way i seem to be able to apply this is by making an array that goes through the title attributes like this: $optionalclasses = array( ($item->attr_title == 'contact' ? 'contact' : '')); Commented Nov 5, 2016 at 8:19
  • Okay if i am not mistaken it is not possible to get just the optional class from the classes array ($item->classes). Though i found a way around this by adding the title as an class: ( ! empty($item->attr_title) ? $item->attr_title : '') Commented Nov 5, 2016 at 9:08