Friday 30 November 2012
Facebook StumbleUpon Twitter Google+ Pin It

Vertical Menu - Wordpress

For vertical menu or changing the id of dynamic menu:-

  • Goto root folder

  • websitename/wp-includes/nav-menu-template.php

  • Probably line no. :-137 or find the below function

  • Add the bold character string to the function.

  • once you are done with this add 2 files(css & js) & include both of them (define) in header.php of your theme.

  • you can find the file codes at the end of the code.

function wp_nav_menu( $args = array() ) {
static $menu_id_slugs = array();

$defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu glossymenu', 'menu_id' => 'verticalmenu',
'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'items_wrap' => '<ul id="%1$s">%3$s</ul>',
'depth' => 0, 'walker' => '', 'theme_location' => '' );

cssverticalmenu.css

.glossymenu, .glossymenu li ul{
list-style-type: none;
margin: 0;
padding: 0;
width: 200px; /*WIDTH OF MAIN MENU ITEMS*/
}

.glossymenu li{
position: relative;
}

.glossymenu li a{
background: url(../images/li_bg.jpg) repeat-x bottom left;
font: bold 12px Verdana, Helvetica, sans-serif;
color: white;
display: block;
width: auto;
padding: 8px 0 12px 10px;
border: 1px solid #004623;
text-decoration: none;
}

.glossymenu li ul{ /*SUB MENU STYLE*/
position: absolute;
width: 190px; /*WIDTH OF SUB MENU ITEMS*/
left: 0;
top: 0;
display: none;
}

.glossymenu li ul li{
float: left;
}

.glossymenu li ul a{
width: 180px; /*WIDTH OF SUB MENU ITEMS - 10px padding-left for A elements */
}

.glossymenu .arrowdiv{
position: absolute;
right: 12px;
top: 13px;
background: url(../images/arrow.png) no-repeat;
}

.glossymenu li a:visited, .glossymenu li a:active{
color: white;
}

.glossymenu li a:hover{
background:url(../images/li_bg_hover.jpg) repeat-x;
}

/* Holly Hack for IE \*/
* html .glossymenu li { float: left; height: 1%; }
* html .glossymenu li a { height: 1%; }
/* End */

----------------------------------------------------------------------------------------------------------------------------------------------------------------------

cssverticalmenu.js

var menuids=new Array("verticalmenu") //Enter id(s) of UL menus, separated by commas
var submenuoffset=-2 //Offset of submenus from main menu. Default is -2 pixels.

function createcssmenu(){
for (var i=0; i<menuids.length; i++){
var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
for (var t=0; t<ultags.length; t++){
var spanref=document.createElement("span")
spanref.className="arrowdiv"
spanref.innerHTML="&nbsp;&nbsp;"
ultags[t].parentNode.getElementsByTagName("a")[0].appendChild(spanref)
ultags[t].parentNode.onmouseover=function(){
this.getElementsByTagName("ul")[0].style.left=this.parentNode.offsetWidth+submenuoffset+"px"
this.getElementsByTagName("ul")[0].style.display="block"
}
ultags[t].parentNode.onmouseout=function(){
this.getElementsByTagName("ul")[0].style.display="none"
}
}
}
}


if (window.addEventListener)
window.addEventListener("load", createcssmenu, false)
else if (window.attachEvent)
window.attachEvent("onload", createcssmenu)



No comments: