Two built-in features of WordPress make this easy to accomplish, without any code: body tag classes, and the ability to add a class to a menu item.
Any author archive pages will have the classes ‘archive’ and ‘author’ in the tag (along with others, including author-name and author-id).
You can add a class to a menu item by opening the Screen Options tab on the menu page and clicking the ‘CSS Classes’ checkbox. Add a class name and save the menu.
In your CSS, you can then target that menu item when the body tag has ‘author’ class.
Example:
body.author .menu-item.myclassname { active state rules here }
Related Posts:
- Changing the Order of Admin Menu Sections?
- Filter wp_nav_menu()
- remove “edit your profile” from admin menu bar
- add custom class to wp_nav_menu using filter hook nav_menu_css_class
- Show just one level of child pages, wp_list_pages woe
- add span class inside wp_nav_menu link anchor tag
- Using filters to change href of nav menu page link
- Menu is invisible in admin panel but it’s visible in front-end [closed]
- replace current_page_item class in menu
- Adding attributes to link in wp_nav_menu using custom Walker function
- How to add current, parent, and ancestor menu item IDs to body_class()?
- How to manually add an item to a submenu in a menu generated by wp_nav_menu?
- Walker_Nav_Menu: put custom code between a particular
- Remove navigation from header in custom page template
- How to create a custom menu item
- Disguise Multi-Page site as Single Page
- How to specify or extend the CSS-class of a menu item?
- Change image based on menu item id
- Add div to specific sub-menu
- Add Bootstrap dropdown class to a nav menu
- WordPress Add javascript:void(0); to menu link item?
- Search box as a menu item in the nav menu output by wp_nav_menu?
- How to change Twenty Seventeen theme’s navigation bar location?
- Making WordPress’ page and menus visible only for logged in users, checking session variables
- How can I put two menus in the same div?
- Add static item to wp_nav_menu
- Indirect modification of overloaded property WP_Post::$classes has no effect
- WordPress – site with 2 stylesheets and more…
- Add nav menu CSS class to body
- Menu Custom link – using relative link when WP is in a subdirectory
- How to add a CSS class to the tooltip on a navigation menu?
- Using Shortcodes in WP-Menus in WP 3.1 (via nav_menu_objects)?
- WooCommerce dynamic menus
- Hide menu item based on user’s custom capability
- Auto add pages to primary menu with functions.php
- Add id to menu items in wp_nav_menu
- How to get the name of the parent menu if the current page is an archive page in a custom menu
- Add dynamic Sitemap to footer
- Making sub-menus exclusive [closed]
- How do I separate link levels in a custom menu walker?
- Possible Menu Hack?
- how can i add css class on current page in wordpress wp_nav_menu
- How to rewrite the output of wordpress nav menu?
- Return Page/Post ID’s of Child WP_Nav_Menu items
- I need my dropdown sub-sub-menu box to show sub-menu title above
- Custom Links menu items include in Search Results
- When clicking on menu item not going to specific page
- Static page to one page- menu inactive items highlighted
- Menu items suddenly are displayed all over the page [closed]
- Custom navigation structure with walker class
- CSS Classes (optional) on menu is not showing
- Why is only the first operation run in my loop – except for on the last repeat? [closed]
- Move Sticky Nav Menu Below WordPress Tool bar when tool bar enabled
- Prevent menu from loading in a page template [duplicate]
- How to use wp_nav_menu with hashtag links?
- How to hide a menu from public, but share content with a private link [closed]
- Add custom link on the fly to nav menu
- URL links consistent with menus?
- Strange menu behaviour wordpress admin [duplicate]
- How to check if current page is a parent item or child item in a given menu
- changing the labels inside appearance -> menus for some for the fields
- Lost admin “manage_link” capability WordPress. No “Links” menu item in admin menu
- How to add active class to separate page link?
- Buggy wp_nav_menu?
- dropdown menu, with walker
- Add function to custom menu
- WP Menu Rollover Nav Item and Effect DIV Elsewhere
- Custom menu with additional logic for display
- Menu item that hides when you click the previous submenu
- Putting footer links into different columns
- Add/remove image from navigation bar
- How can I order these pages in this navigation bar on this old wordpress theme?
- How to create a mobile menu full screen overlay using Understraps Bootstrap 4 theme
- adding drop down menu item to existing menu
- wordpress walker add class to submenu a href
- Display searchform in the menu
- Add href to tag in nav menu for mobile
- How to change navwalker’s dropdown mark-up?
- Bootstrap navbar responsiveness on WordPress theme menu not working
- Unable to remove page from primary menu
- Show navigation header menu by post and categery
- How to add a toggle on the left side of my page?
- How to add buddypress sub-menu items to other menus
- Custom location for menu
- No indication of menu
- Always show wordpress submenu on responsive header menu
- add custom entries to menu options
- jQuery not working when used with wordpress menu
- How to display list of child pages with parent in wordpress?
- Theme: Twenty Thirteen Mobile Sliding Menu Doesn’t Bump Content Down
- Show content of subdomain from specific menu-item?
- Update nav menu item position programmatically
- wp_nav_menu – Collapse with PHP
- How can I disable sorting/dragging of a menu item in the custom menu admin?
- How to add or remove borders in navigation menu?
- buddypress slug issues [closed]
- WordPress menu is getting automatically nested
- WordPress removes URL parameters from menu elements when saving the menu
- Give custom class names to WP nav sub-menu
- How to hide an item from nav menu on desktop view?(without plugin)