So, I’ve built sites with dynamic vertical navigation menus. However, I can’t quite figure out how to create a dynamic drop down menu in wordpress. You can see on here that I am calling the Main Nav menu twice here. I did it once styled and a second time with no styling. I did this to show that the code is calling the navigation properly but that it won’t show when the CSS is applied.
So, this is what I did.
[B]
- Create the pages (Home > About us, Services)
- Created the menu ‘Main Nav’
- Added the code to the Header[/B]
CODE
<?php if (function_exists('dynamic_sidebar')) : else : ?>
<?php endif; ?>
<ul id="nav">
<?php wp_nav_menu(array('menu' => 'Main Nav')); ?>
</ul>
<ul>
<?php wp_nav_menu(array('menu' => 'Main Nav')); ?>
</ul>
[B]4) Put in the CSS that I have working properly on another site to test this. http://binghamdentalutah.com/[/B]
#nav{
list-style:none;
font-weight:bold;
background:#9C1F1B url("http://Connect4WebDesign.com/wp-content/themes/Connect 4 WP/images/Nav background.png") repeat-x;
height:66px;
margin-top:-10px;
margin-bottom:0px;
}
#nav li{
float:left;
margin-right:0px;
position:relative;
font-size:20px;
padding-right:15px;
}
#nav a{
display:block;
padding:5px;
color:#0169dc;
text-decoration:underline;
}
#nav a:hover{
text-decoration:underline;
color:#FFFFFF;
}
/*--- DROPDOWN ---*/
#nav ul{
background:#fff; /* Adding a background makes the dropdown work properly in IE7+. Make this as close to your page's background as possible (i.e. white page == white background). */
background:rgba(255,255,255,0); /* But! Let's make the background fully transparent where we can, we don't actually want to see it if we can help it... */
list-style:none;
position:absolute;
left:-9999px; /* Hide off-screen when not needed (this is more accessible than display:none;) */
}
#nav ul li{
padding-top:1px; /* Introducing a padding between the li and the a give the illusion spaced items */
float:none;
font-size:18px;
}
#nav ul a{
white-space:nowrap; /* Stop text wrapping and creating multi-line dropdown items */
color:#FFFFFF;
}
#nav li:hover ul{ /* Display the dropdown on hover */
left:-40px; /* Bring back on-screen when needed */
}
#nav li:hover a{ /* These create persistent hover states, meaning the top-most link stays 'hovered' even when your cursor has moved down the list. */
background:#06C;
text-decoration:underline;
border:thin #ffffff solid;
color:#FFFFFF;
}
#nav li:hover ul a{ /* The persistent hover state does however create a global style for links even before they're hovered. Here we undo these effects. */
text-decoration:none;
}
#nav li:hover ul li a:hover{ /* Here we define the most explicit hover states--what happens when you hover each individual link. */
background:#0066FF;
}
#nav li:hover ul li a:active{ /* Here we define the most explicit hover states--what happens when you hover each individual link. */
background:#8cc63f;
}
Well, if anyone can toss me some helpers here it would be great. thx