WordPress does in fact add a current class by default:
check where it says:
<li id="menu-item-1688" class="current-menu-item">
Within your source code.
Now as for the other item, this is a bit tricky.
There is two ways to do it assuming that you need the last item for styling.
Option #1 is with pure CSS using the last-of-type selector.
Option #2, is using the get_wp_nav_menu as opposed to wp_nav_menu
and once you are inside the foreach
, you compare it using count and the current index of said foreach
to add the css class dinamically.
Edit: If you are a bit new to WordPress theming, I would definitely go with option number 1 despite not having full browser coverage.
Related Posts:
- Add custom menu item using wp_nav_menu_items filter
- Removing link ” from ” menu for some “links” without JS
- Using filters to change href of nav menu page link
- Links open only on new tab or window
- How to get current page menu item name instead of full menu item list
- Adding different classes to anchor in navigation menu
- Pending Custom Link in Menu
- Indirect modification of overloaded property WP_Post::$classes has no effect
- Force PDF download from custom menu?
- Page-Linking Structure
- How to add wechat (weixin) link to navigation menu?
- Admin only menu/page
- Image as a link using wp_nav_menu()
- Link that refers to a menu item with dynamically generated URL
- Fragment URL in navigation item without a custom link
- Link to Homepage in Menu
- Separator for custom nav menu
- How do you link to a place in another page without any styling issues?
- Custom Links menu items include in Search Results
- Menu custom link not working for external site
- Why is wordpress forcing https link generation?
- Links do not open from click, only in new tab [closed]
- Adding existing links to custom navigation menus?
- How to change the link on the logo at the menu?
- Creating Menu Links in a Custom Theme
- The cart, checkout, and shop links not getting removed
- URL links consistent with menus?
- Opening Menu link in another tab
- Active class to current link
- Simple form to add custom links to menu?
- Main menu navigation links and new pages
- custom menu widget where menu title is a link
- 2 item in a same menu pointing to 1 page
- How to show pages in menu without link
- Problem with links once in portfolio item
- How to create a link-less parent (top level) menu item that doesn’t use an anchor tag
- Menu links URL with PHP GET method
- Classes CSS (Optional) – how do I reference this in php?
- Why does WordPress convert absolute URLs to relative URLs for menu items?
- Parent link need to go first child submenu
- Add a data attribute to list item element in menu
- Links in new menu don’t work
- How to make menu output links absolute
- change link of menu particular tab
- Menu Structure with Links failure to update
- Top menu link anchor href value change after online server?
- Show content of subdomain from specific menu-item?
- Navigational error
- How do I add a link to the menu that has a charector (?) in it?
- Remove link from Page name in navigation bar
- Change menu item order
- Menu System: Custom Links
- Unsual behaviour of navigation Menus
- How to centre menu items on horizontal nav bar? (e.g. make margins equal) [closed]
- Wrapping my ‘s with
- Displaying list of random links using wp_nav_menu
- WordPress removes URL parameters from menu elements when saving the menu
- how to add permalink/slug to wordpress custom link menu item
- Main Menu Hover is Always White
- Display only page specific sub menu items using Custom Walker
- non-clickable placeholder in the menu
- Ways to give a wp_list_pages menu link specific class names?
- I want remove last after wp_nav_menu
- wp_list_pages – show pages immediately 1 level below current level
- Vertical Sidebar Menu Parent and Child not displaying correctly [closed]
- How to show Home Page link in WordPress Menu and how to add an icon to this?
- How do you return a menu with the menu name?
- do_action appearing outside of menu?
- You do not have permission to create Navigation Menus – Twenty Twenty-Two theme
- Walker class conditional based on parent menu item label or custom css class
- ‘wp_get_nav_menu_items’, when fired inside of the ‘wp_update_nav_menu’ hook, returns old menu items, instead of new
- Walker Class – Check if menu item has description and if so add class to li
- Multiple languages menus problem
- How to override menu markup?
- How to remove dropdown from wp_nav_menu
- Recent Posts widget missing current_menu_item class
- Static site menu with multiple ul’s to wp menu
- How can I make wp_nav_menu() support tags?
- Filter to hook into menu items and add a custom attribute
- how to set the link in wordpress such that on clicking it doesn’t open another page but go to the bottom of same page
- custom walker class for own menu?
- Add a menu metabox to post edit page
- Setting or plugin for showing submenus horizontally under the main menu, and keep them after selection
- New wp menu menu styling
- (Mobile) Hamburger menu disappeared from a page (only one)
- Hiding menu on specific pages
- Bootstrap Menu bar shows up a toggle in Desktop Mode
- For a menu custom link (without a link) a “#” is appended. Can this just be blank, i.e. NO link?
- sidebar navigation problem with child pages not all display.?
- How to point menu to my homepage
- save_post() on Menu Save
- update_post_meta breaking wp_update_nav_menu_item
- Building a menu from a large number of pages?
- How do I remove a menu from a theme?
- Access CSS Classes specified in Menu options
- How to output the menue structured for tabbed navigation?
- Custom Menu based off custom header
- Adding an additional menu in WordPress
- Making current_page_item work with wp_list_pages in sidebar on post pages
- WordPress “add to menu” button not working