Wordpress Menu Register And Dynamic
WordPress menu register and dynamic process. at first, you need to register the menu in your WordPress theme functions.php file. then you should go to your WordPress theme header.php file, then use the wp_nav_menu() function.
// Menu Register . use this code functions.php
function carnewstheme_menu() {
if (function_exists('carnewstheme_menu')) {
register_nav_menu( 'header_top_menu', __('Header Menu', 'carsnewstheme'));
register_nav_menu( 'footer_menu', __('Footer Menu', 'carsnewstheme'));
}
}
add_action('init', 'carnewstheme_menu');
//Then, use these code Header.php for display menu in your wordpress theme
<div class="col-md-9">
<div class="nav-wrapper">
<nav class="main-navigation">
<?php
wp_nav_menu(array(
'theme_location' =>'header_top_menu',
'container_class' =>'main-navigation',
'items_wrap' =>'<ul class="main-menu">%3$s</ul>'
) );
?>
</nav>
</div>
</div>
No comments