Last Updated: February 25, 2016
·
966
· rajeshkhatri13

Wordpress navigation register and how to call?

Add below code in function.php

function registermymenus() {
  registernavmenus(
    array(
      'header-menu' => _( 'Header Menu' ),
      'extra-menu' => _( 'Extra Menu' )
    )
  );
}

addaction( 'init', 'registermy_menus' );
</code></pre>

<h2>Add below code in <i>template file</i></h2>


<?php wpnavmenu( array( 'theme_location' => 'header-menu' ) ); ?>
</code>
</pre>

For adding class in menu


<?php wpnavmenu( array( 'themelocation' => 'header-menu', 'menuclass' => 'topnav', ) ); ?>
</code></pre>

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Related Tags
#wordpress
Did you know?

WordPress sites collect scripts from themes, plugins, and tag managers. A compromised plugin update can add a skimmer to every page without a change in your own templates.

Security insights from Cside