Opened 14 years ago
Closed 14 years ago
#13379 closed enhancement (fixed)
wp_nav_menu item classnames
Reported by: | silencematters | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.0 | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | Menus | Keywords: | |
Focuses: | Cc: |
Description
When adding an existing PAGE as a menu-item, there is currently no way to target that menu-item.
Adding the page-slug as a classname to the menu-item when a PAGE is used would help, as would a classname that appears when on that given page.
Attachments (2)
Change History (12)
#2
@
14 years ago
Good points. I agree that doing it just for just pages might be a bit narrow.
It might be the most flexible if defined as just adding the post-slug as a classname, which spans across many custom post-types and taxonomies.
The current list of classes on a menu-item are:
<li class="menu-item menu-item-type-post_type menu-item-object-page">
Adding one more classname would enable a world of styling possibilities.
#3
in reply to:
↑ 1
@
14 years ago
Replying to nacin:
I think part of the issue is where you draw the line.
I think doing it just for pages is a little narrow, if we're going to do it. Is doing it for all post types and taxonomies too much markup?
I imagine there's already a filter to achieve this as well. Patches and thoughts welcome.
I'd go with a filter, that way a custom post type or other plugin/theme can add classes through the filter. The only way the CSS will be there for the extra classes is through plugin/theme functions.
#4
@
14 years ago
How about handle the default post types and taxonomies with built in class names, and let customs get handled by plugin writers... is there an API for that?
#5
@
14 years ago
I've been meaning to revisit this. At the very least pages deserve classes, along with a filter to handle the rest.
I think part of the issue is where you draw the line. In addition to pages, there's also other post types, including posts and any custom types. Some are hierarchical, some are not. Then there's categories, again hierarchical (do we list parents in some way?), tags, and custom taxonomies.
I think doing it just for pages is a little narrow, if we're going to do it. Is doing it for all post types and taxonomies too much markup?
I imagine there's already a filter to achieve this as well. Patches and thoughts welcome.