Giter Club home page Giter Club logo

bootstrap-navwalker's Introduction

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>

bootstrap-navwalker's People

Contributors

mebishalnapit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

bootstrap-navwalker's Issues

Duplicate ID in w3c Validator

Hello,
After integration in Undescrore Starter Theme and validate by w3c validator...
It says ID are duplicated in menus and submenus.

To resolve i tried to replace:
LINE 29:
id="navbar-dropdown-menu-link-
BY
id="navbar-dropdown-submenu-link-

to make the difference with:
LINE 194

Does it seems to be a good solution?

Container is missing

Hello @mebishalnapit .
Thank you very much for sharing this excelent BS Nav Walker which is working with BS 4.3.1 perfect - except the container. I call it this way:

array(
'theme_location'  => 'header-menu',
'container_class' => 'collapse navbar-collapse',
'container_id'    => 'navbarCollapse',
'menu_class'      => 'navbar-nav mr-auto nav-pills',
'menu_id'         => '',
'walker'         => new Bootstrap_NavWalker(),
'fallback_cb'    => 'Bootstrap_NavWalker::fallback'
)

As I noticed the output of the container is missing. Because I use different container it would be wonderfull if you can have a look into this issue and add the output of the container as well.
Thank you in advance.

Hover and dropdown not working

Just recently, our nav menu is not hovering the dropdowns anymore and also in addition the mobile version is not showing the whole meu.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.