Make WordPress Core

Opened 11 months ago

Last modified 10 months ago

#58857 new enhancement

Menu class should be in BODY tag

Reported by: lukedouglas's profile LukeDouglas Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.2.2
Component: Menus Keywords:
Focuses: Cc:


Currently, if you assign a class to a menu item, the class is only usable to the menu link alone. It would be 'very' beneficial to have the class in the BODY tag. If you want to keep them separate, you could preface the class with 'body-'.

So I have a menu link for 'Sponsors' and I assign the class 'g-sponsor' to the menu link.

Right now, it would show similar to this:

<li class="g-menu-item g-menu-item-648 g-menu-item-type-taxonomy g-sponsors">
<a class="g-menu-item-container" href="">
<span class="g-menu-item-content">
<span class="g-menu-item-title">Sponsors</span>

It would be great to have it added to the body class like this:

<body class="gantry g-offcanvas-left g-home g-sponsors g-style- home page-template-default page page-id-13 logged-in site outline-home dir-ltr">

This the class can be use for 'any' element on the page instead of just the menu link.

FYI, I have a lot of experience in Joomla and they have had this functionality since the beginning. Now that I am migrating all Joomla websites to WordPress, I no longer have this functionality.

It should be a core function of the menu class.

Just a suggestion.

Luke Douglas

Change History (1)

This ticket was mentioned in Slack in #forums by nekojonez. View the logs.

10 months ago

Note: See TracTickets for help on using tickets.