This question was also asked on stackoverflow. Here’s a copy of the answer i gave there:
Perhaps you could style it using the nth-of-type
CSS3 selector.
.current-menu-item:nth-of-type(1) {
background:#ffff00;
/* Highlight styles */
}
These styles would target only the first occurrence of the .current-menu-item. Likewise, you could choose to target the second with nth-of-type(2)
, et cetera.
Related Posts:
- wp_nav_menu not highlighting the current category when viewing a single post
- Open subcategories in submenu on click in primary menu
- Create menu / submenu from category subcategory and posts
- Give Children Unique ID’s
- Theme for subcategories
- Multiple categories for one menu item?
- Global navigation in multisite: problem with categories
- How to add all subcategories as submenu in WordPress menu
- omit categories from main navigation menu
- How to create an automatic MultiColoumn MegaMenu with Categories WordPress
- Get the children of the parent category
- Gutenberg editor add a custom category as wrapper for custom blocks
- How can I hide a category from Contributors in the edit/add new post screen?
- WordPress Multiple Category Search
- How to remove categories filter from wordpress admin?
- Creating “static” taxonomies to choose from, inside custom post type?
- Decreasing the Memory Consumption of a WordPress Site?
- wp_nav_menu not appearing for a couple pages
- Main menu not appearing on category pages
- Multiple Domain Names – One WP Install (non-Multisite) – Default Each Domain name to Category Archive
- How can I select a primary category?
- how to use a different domain/subdomain for authors/catagories on single site?
- Deleting default category in wordpress
- Delete a specific category when deleting a user
- Custom Nav Walker menu – Display category count
- Reflect nested categories in appearance > menus
- How to list child categories in custom category template?
- Trash bin for categories
- How to set up sub-categories for author pages?
- View category in the preview of Theme Customizer
- Category menu item and its last 10 posts as sub-menu
- One WordPress Install, Two Categories. Each Category Gets a Domain
- Block multiple categories from Blog
- Is there a function to cause empty categories not to show in menus?
- How to have a static category/author page?
- Create single.php for specific category by category id
- Show posts of one category only with Custom Taxonomy on single.php
- Assign different category colours to different categories in the main menu
- Extend walker – navigation, adding data attribute to a tag
- Save metabox checkboxes values to custom content type
- Keep active class in post page
- Auto add pages to category menu
- How to show empty category in admin menus search
- Select category in custom query
- Add custom taxonomy terms to WordPress menu dynamically & append #slug to url
- Display WooCommerce product categories in a 4 columns custom menu [closed]
- Is it possible to put next and previous category links?
- Remove “Parent” Selection When Adding/Editing Categories?
- wp_nav_menu doesn’t generate parent/ancestor classes
- Can this navigation be done easily in WordPress?
- Order Taxonomy Term by date created
- Automatically add product_categories to nav_menu
- Apply custom category template to subcategories
- Hide post meta data on a specific category
- Previous/next link to post in category, NOT tag?
- Hide Login information in Account settings in Buddy Boss
- Add Product categories to WordPress menu without losing hierarchy
- Custom Category/Subcategory structure
- Format Brand value in Category view [closed]
- Add custom taxonomy under the category title
- How to show in search results posts with a particular tag in a particular category?
- Add a specific category at a specific place to the menu that uses wp_list_pages
- Using Shortcodes in WP-Menus in WP 3.1 (via nav_menu_objects)?
- What is the advantage of using header-catname.php over is_category(‘catname’);?
- Remove ‘rel’ attributes from the_category() output
- in_category() works in single.php but not in page.php?
- Show recent posts in menu?
- Use a wordpress page to display a certain category
- How to view WordPress’ default category IDs?
- Show Different Custom Menu on Different Category Pages
- Multiple Category Search
- How do I add a function on a specific post category?
- How to add Categories to the top menu of the website?
- Implementing a tricky wordpress menu (nested categories + thumbnails)
- Looking for the best solution to build this Blog structure? Picture attached?
- Nav menu category links not showing
- How to customize category template?
- Category-slug.php not being used
- Programmatically (PHP) get the nr. of items in the primary navigation menu
- How to display only posts assigned to a particular, isolated, subcategory
- Show number of articles in menu
- How would I go about adding custom header images per category?
- How to show only one category in breadcrumb navigation
- Automatically adding categories and authors in custom menu?
- Hard coded main navigation
- Highlight wp_nav_menu when category is selected
- Checkboxes in the category list?
- Automatically exclude categories from metabox based on title
- Display posts separated by Category in Author’s page
- Class active for Archive link – looped out
- Add clickable arrows to parent menu items with children elements e.g. with
- Restoring default article pagination on archives – Removing custom limits
- How to categorize posts under Category 1 and Category 2 which are separate lists of categories, and display them as separate lists in widgets
- previous/next_post_link in the same sub-category?
- How to wrap the list with custom class using wp_nav_menu?
- How to organize custom categories for filtering and selecting
- Menus don’t work after 4.4 [closed]
- category permalinks
- Categories as main menu items and subcategories as nested lists
- Filtering *out* a taxonomy from the admin post list