Home » Webtips » Add Classes to First and Last Menu Item in WordPress
Webtips

Add Classes to First and Last Menu Item in WordPress

Add Custom Menu class to First and Last menu item of WP Nav Menu. The following function will generate seperate class for the first and last menu item in WordPress Menu. Thus we can apply custom style to those menu items.

Add the following function in your function.php file

Here ‘wp_menu_first’ and ‘wp_menu_last’ are the two classes generated for first and last menu item.

You can so easily style those menu item using these classes in your style.css file.

About the author

Vipin

Hi, i am Vipin, a programmer working in Dubai, UAE. I love blogging, and so started TechRounder for sharing my findings and other digital informations with others too. Please feel free to share your feedback with me in the comment section below or you can email me at vipin@techrounder.com.

17 Comments

Click here to post a comment

Your email address will not be published. Required fields are marked *

Get latest updates
in your inbox

Subscribe to TechRounder mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.