How to convert HTML menu to wordpress Menu
When you need to convert HTML menu to wordpress menu, this tutorial will be very helpful for you.
At first I show you the code for sample HTML menu code:
CSS code for above HTML code is :
#nav
{
padding: 0 5px;
height: 40px;
/*float: right;*/
position: absolute;
top: 0;
right: 20px;
font-family: Helvetica, arial, sans-serif;
background: url(../images/paper.jpg);
border: 1px solid #dcd7d2;
border-top: 0;
-moz-border-radius-bottomleft: 4px;
-moz-border-radius-bottomright: 4px;
-webkit-border-bottom-left-radius: 4px;
-webkit-border-bottom-right-radius: 4px;
-border-bottom-left-radius: 4px;
-border-bottom-right-radius: 4px;
}
#nav ul
{
z-index: 20;
}
#nav li
{
list-style: none;
float: left;
position: relative;
margin: 0;
padding: 5px 0 40px;
}
#nav a
{
float: left;
padding: 7px 15px 11px;
min-height: 12px; /* min-height will allow an item to occupy multiple lines */
line-height: 100%;
text-decoration: none;
font-size: 1.1em;
text-shadow: 0 1px 0 #fff;
font-style: normal;
color: #241506;
}
#nav li.parent > a
{
background: url(../images/nav.png) no-repeat 50% -58px;
}
#nav li.active
{
background: url(../images/nav.png) no-repeat 50% 41px;
}
/* Second level
------------------------------------------ */
#nav li ul
{
position: absolute;
top: 40px;
left: -5px;
display: none;
padding: 10px 0 5px !important; /* Important so the slide functions don't overwrite it */
background: url(../images/paper.jpg);
border: 1px solid #dcd7d2;
border-top: 0;
-moz-border-radius-bottomleft: 4px;
-moz-border-radius-bottomright: 4px;
-webkit-border-radius-bottomleft: 4px;
-webkit-border-radius-bottomright: 4px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
}
#nav li li
{
margin: 0;
border: 0;
padding: 0 5px;
}
#nav li li a
{
width: 140px;
display: block;
float: none;
padding: 10px;
}
#nav li li.parent > a
{
background: url(../images/nav.png) no-repeat 100% -122px;
}
/* Third level
------------------------------------------ */
#nav ul ul ul
{
top: 0;
left: 100%;
padding: 5px !important;
margin: -5px 0 0 0px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
}
Now, need to convert this HTML menu to wordpress menu:
Step-1: At first copy paste the below code to your functions.php file
if ( function_exists( 'register_nav_menus' ) ) {
register_nav_menus(
array(
'menu_1' => 'Menu 1',
)
);
}
Step-2: Now change the above red color code
At first I show you the code for sample HTML menu code:
CSS code for above HTML code is :
#nav
{
padding: 0 5px;
height: 40px;
/*float: right;*/
position: absolute;
top: 0;
right: 20px;
font-family: Helvetica, arial, sans-serif;
background: url(../images/paper.jpg);
border: 1px solid #dcd7d2;
border-top: 0;
-moz-border-radius-bottomleft: 4px;
-moz-border-radius-bottomright: 4px;
-webkit-border-bottom-left-radius: 4px;
-webkit-border-bottom-right-radius: 4px;
-border-bottom-left-radius: 4px;
-border-bottom-right-radius: 4px;
}
#nav ul
{
z-index: 20;
}
#nav li
{
list-style: none;
float: left;
position: relative;
margin: 0;
padding: 5px 0 40px;
}
#nav a
{
float: left;
padding: 7px 15px 11px;
min-height: 12px; /* min-height will allow an item to occupy multiple lines */
line-height: 100%;
text-decoration: none;
font-size: 1.1em;
text-shadow: 0 1px 0 #fff;
font-style: normal;
color: #241506;
}
#nav li.parent > a
{
background: url(../images/nav.png) no-repeat 50% -58px;
}
#nav li.active
{
background: url(../images/nav.png) no-repeat 50% 41px;
}
/* Second level
------------------------------------------ */
#nav li ul
{
position: absolute;
top: 40px;
left: -5px;
display: none;
padding: 10px 0 5px !important; /* Important so the slide functions don't overwrite it */
background: url(../images/paper.jpg);
border: 1px solid #dcd7d2;
border-top: 0;
-moz-border-radius-bottomleft: 4px;
-moz-border-radius-bottomright: 4px;
-webkit-border-radius-bottomleft: 4px;
-webkit-border-radius-bottomright: 4px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
}
#nav li li
{
margin: 0;
border: 0;
padding: 0 5px;
}
#nav li li a
{
width: 140px;
display: block;
float: none;
padding: 10px;
}
#nav li li.parent > a
{
background: url(../images/nav.png) no-repeat 100% -122px;
}
/* Third level
------------------------------------------ */
#nav ul ul ul
{
top: 0;
left: 100%;
padding: 5px !important;
margin: -5px 0 0 0px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
}
Now, need to convert this HTML menu to wordpress menu:
Step-1: At first copy paste the below code to your functions.php file
if ( function_exists( 'register_nav_menus' ) ) {
register_nav_menus(
array(
'menu_1' => 'Menu 1',
)
);
}
Step-2: Now change the above red color code