Metadata
- Source
- SNOW-9
- Type
- Task
- Priority
- Major
- Status
- Closed
- Resolution
- Fixed
- Assignee
- Eloisa Guerrero
- Reporter
- Eloisa Guerrero
- Created
2018-02-02T13:40:17.738-0500 - Updated
2018-07-12T15:38:32.378-0400 - Versions
- N/A
- Fixed Versions
- N/A
- Component
- N/A
Description
Right now the menu does not show the current indicator for posts with subcategories. Will need to programmatically get the current category of the post, and set its root category with the current-menu-item class so that the black line indicator for the correct category shows up on each of these posts.
See mockup (currently B&W with white line indicator): https://files.inclusivedesign.ca/f/33422
Comments
-
Eloisa Guerrero commented
2018-02-04T15:18:11.976-0500 To activate the breadcrumbs to the original/main category, we need to add 'current-menu-item' CSS class based on the 'current-post-ancestor' (or 'current-page-ancestor') class of the current page or post. Thus:
function make_current_menu_item( $classes, $item ) { if (in_array('current-post-ancestor', $classes) || in_array('current-page-ancestor', $classes) || in_array('current-menu-item', $classes) ) { $classes[] = 'current-menu-item'; } return $classes; } add_filter( 'nav_menu_css_class', 'make_current_menu_item', 10, 2 );