• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Menu
  • Back to Top
  • Services
    • Web Design
    • Graphic Design
    • Web Hosting
  • Portfolio
  • Pricing
    • FAQ’s
  • About Me
    • Blog
    • Contact

Automatically Add Menu Item Titles to Menu Item CSS Classes

March 7, 2018Dan BrubakerComment

If you are adding individual CSS styles to your menu items, you might want to automatically add the title of the menu item to its CSS classes. You can always do it manually like this, but adding it automatically can help prevent user error.

You could always style using the menu item’s “menu-item-ID” class, but I prefer to have a more descriptive class to work with.

Simply add this code to your theme’s functions.php file, and you will see a “menu-item-TITLE” class automatically added to each menu item.

https://gist.github.com/danbru1989/082b5f332f974ee3d565457b692cc81b

Filed Under: Tips & Code Snippets Tagged With: navigation, php

About Dan Brubaker

I am a husband, father, evangelist, web designer, and sometimes farmer. My family and I live full-time in an RV and travel around representing Servant's Heart Camp. My workspace is small, but the window view is great!

Reader Interactions

Leave a Reply Cancel 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.

Primary Sidebar

Contact Me

  • (717) 991-1426
  • danbru@gmail.com

Mailing Address:


5050 Colebrook Road
Hershey, PA 17033

RSS Ministry Updates

  • Ministry Changes & Moving November 4, 2020
  • Revival Ministry and HFA Crusade September 23, 2020
  • Attend Our Online Rally! April 16, 2020
  • Winter Ministry & Outreach February 11, 2020
  • Happy New Year! January 1, 2020
  • Last Meeting And Winter Work November 18, 2019
  • Continued Fall Revival Meetings November 4, 2019
  • Visiting The Quecreek Mine Rescue October 14, 2019
  • Menu
  • Back to Top
  • Services
    • Web Design
    • Graphic Design
    • Web Hosting
  • Portfolio
  • Pricing
    • FAQ’s
  • About Me
    • Blog
    • Contact

    Services

  • Web Design
  • Graphic Design
  • Web Hosting

    Information

  • About Me
  • Portfolio
  • Pricing
  • Privacy

    Contact Me

  • (717) 991-1426
  • danbru@gmail.com
Log In
Copyright © 2023 — Brubaker Design Services