php - how to add menu in wordpress website -
how can add wordpress menu? tried seems not working. looking way add dropwon menu . e.g. using version 3.6.1
dopdown menu
<div class="nav-wrap"> <ul class="nav"> <li class="on"> <a href='index.html' ><?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?></a> </li> <li> <a href='#'>about us</a> <ul class="subnav"> <li><a href='companyhistory.html'>company history</a></li> <li><a href='visionstatement.html'>vision statement </a></li> <li><a href='missionstatement.html'>mission statement </a></li> <li><a href='values.html'>values </a></li> <li><a href='ourpromisetoyou.html'>our promise you</a></li> </ul> </li></ul> </div>
but found out not work on wordpress. tried wordpress built in menu, still not work.
function.php
<?php function twentyten_page_menu_args( $args ) { $args['show_home'] = true; return $args; } add_filter( 'wp_page_menu_args', 'twentyten_page_menu_args' ); // theme uses wp_nav_menu() in 1 location. register_nav_menus( array( 'primary' => __( 'primary navigation', 'twentyten' ), ) ); ?>
header.php
<?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?><
in opinion, best way add navigation in wordpress hard-code it. put code header.php file. i've changed in code below:
all wordpress pages .php not .html (unless using static pages made, not typically approach.)
i discarded "on" class. if trying highlight text current page, isn't going work because "header.php" called every page, , no matter page, class "on" applied text home page.
i got rid of wordpress code displaying wordpress menu. don't try use includes hard coded menu. hand small site this.
i added link blog. of dynamic pages come from. (you can go "reading" settings in admin console, , set home page (a static page) , blog page.)) also, can use "blog" anything, not blog. can dynamic photo gallery, support forum, etc. or don't use if don't need blog.
make sure replace "mysite.com" actual address. hardcoded menu, should use full addresses, not relative addresses, if using blog.
<div class="nav-wrap"> <ul class="nav"> <li><a href='http://www.mysite.com/index.php' >home</a></li> <li> <a href='#'>about us</a> <ul class="subnav"> <li><a href='http://www.mysite.com/companyhistory.php'>company history</a></li> <li><a href='http://www.mysite.com/visionstatement.php'>vision statement </a></li> <li><a href='http://www.mysite.com/missionstatement.php'>mission statement </a></li> <li><a href='http://www.mysite.com/values.html'>values </a></li> <li><a href='http://www.mysite.com/ourpromisetoyou.php'>our promise you</a></li> </ul> </li> </ul> <li><a href='http://www.mysite.com/blog.php' >our blog</a></li> </div>
this should give functioning navigation menu can control. making drop-down menu, have apply right css. 1 place start answer posted question few days ago. decent tutorial, marked code:
Comments
Post a Comment