Skip to content

mebishalnapit/bootstrap-navwalker

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 

BOOTSTRAP NAVWALKER

A custom WordPress nav walker class to implement the Bootstrap 4 navigation style in a custom WordPress Bootstrap based theme using the WordPress built in menu manager.

INSTALLATION

Download and place the bootstrap-navwalker file inside your theme folder, ie, inside /wp-content/themes/theme-name/ folder.

Now, require the file via the below PHP code addition inside your functions.php file of the theme:

require get_template_directory() . '/bootstrap-navwalker.php';

USAGE

Once you register the menu via the below PHP code in the funtions.php file:

register_nav_menus( array(
    'menu-1' => esc_html__( 'Primary', 'theme-textdomain' ),
) );

Now, you can display the menu in your theme via below PHP code addition in the header.php file of your theme.

<nav class="navbar navbar-expand-lg navbar-light bg-light">
	<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-content" aria-controls="navbar-content" aria-expanded="false" aria-label="<?php esc_html_e( 'Toggle Navigation', 'theme-textdomain' ); ?>">
		<span class="navbar-toggler-icon"></span>
	</button>

	<div class="collapse navbar-collapse" id="navbar-content">
		<?php
		wp_nav_menu( array(
			'theme_location' => 'menu-1',
			'menu_id'        => 'primary-menu',
			'container'      => false,
			'depth'          => 2,
			'menu_class'     => 'navbar-nav ml-auto',
			'walker'         => new Bootstrap_NavWalker(),
			'fallback_cb'    => 'Bootstrap_NavWalker::fallback',
		) );
		?>
	</div>
</nav>

About

Bootstrap NavWalker based on Bootstrap 4 for WordPress

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages