Skip to content

Instantly share code, notes, and snippets.

@melaniemuellerdesign
Last active December 2, 2018 15:43
Show Gist options
  • Select an option

  • Save melaniemuellerdesign/738cef15585ab9d5d0103d68350eacee to your computer and use it in GitHub Desktop.

Select an option

Save melaniemuellerdesign/738cef15585ab9d5d0103d68350eacee to your computer and use it in GitHub Desktop.
Wordpress sticky Bootstrap header with wordpress und class-wp-bootstrap-navwalker.php
<header id="masthead" class="site-header sticky-top">
<nav class="navbar navbar-expand-sm navbar-dark bg-dark" role="navigation">
<div class="container">
<a class="navbar-brand" href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?> <?php the_custom_logo(); ?></a>
<!-- Brand and toggle get grouped for better mobile display -->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-controls="bs-example-navbar-collapse-1" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<?php
wp_nav_menu( array(
'theme_location' => 'primary',
'depth' => 2,
'container' => 'div',
'container_class' => 'collapse navbar-collapse',
'container_id' => 'bs-example-navbar-collapse-1',
'menu_class' => 'nav navbar-nav',
'fallback_cb' => 'WP_Bootstrap_Navwalker::fallback',
'walker' => new WP_Bootstrap_Navwalker(),
) );
?>
</div>
</nav>
<!-- #site-navigation -->
</header>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment