how to create custom navbar in wordpress



you can easily create a custom menu, which usually serves as a navigation menu for your site. The built-in WordPress Menu feature allows you to create your own custom menus in place of your theme’s default menus.There are two option to create navbar in WordPress

1) use custom code in your WordPress theme

functions.php
<?php

function register_my_menus() {
  register_nav_menus(
    array(
      'primary-menu' => __( 'Primary Menu' ),
      'footer-menu' => __( 'Footer Menu' )
    )
  );
}
add_action( 'init', 'register_my_menus' );
?>

header.php

<?php
wp_nav_menu(array('theme_location' =>'primary-menu',
  'container'=>'ul',
 'menu_class' => 'nav navbar-nav pull-right'
 ));
?>

2) customize menu bar in the dashboard


1). lets started creating a custom nav menu, log in your WordPress site and click to details the Appearance menu of the WordPress Dashboard.

2). Click on the Menus link in the Appearance menu. You see the Menus editor page.

3). Create Your menu name

4). Now you create menu items from the boxes on the left, such as pages, categories, and links.

5). If you want to change which menu options you see from this page, click to open the Screen Options tab. Now you can add other menu items options such as posts, tags or formats, or show advanced menu properties like CSS classes.

No comments