Tuesday, 23 July 2013

How to add custom CSS classes in wordpress last and first menu items?


Go to 
<a> Wordpress admin panel.
<b> Appearance.
<c> Editor.
<d> Open config.php file from 'Themes Functions' section.
<e> Append the following code in 'functions.php' file...
<f> Here last menu item class is 'last' and first menu item class is 'first'.

function wpb_first_and_last_menu_class($items) 
{
$items[1]->classes[] = 'first';
$items[count($items)]->classes[] = 'last';
return $items;
}
add_filter('wp_nav_menu_objects', 'wpb_first_and_last_menu_class');

No comments:

How calulation total value for HTML input text?

<script> $j(document).ready(function(){ $j(":text").keyup(function(){ if (isNaN($j(this).val())) { alert(...