Skip to content

Instantly share code, notes, and snippets.

@metinsaylan
Created January 20, 2015 21:57
Show Gist options
  • Save metinsaylan/b56ca4d490cb88a7437e to your computer and use it in GitHub Desktop.
Save metinsaylan/b56ca4d490cb88a7437e to your computer and use it in GitHub Desktop.
Bootstrap Navbar for WordPress
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Navbar Header -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#collapsible">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'description' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?> // </a>
</div>
<div class="navbar-collapse collapse" id="collapsible" >
<!-- Primary Menu -->
<ul class="nav navbar-nav">
<?php
wp_nav_menu( array(
'menu' => 'primary',
'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())
);
?>
</ul>
<!-- Search Form -->
<form id="searchform" class="navbar-form navbar-right" role="form" action="<?php echo home_url( '/' ); ?>">
<div class="input-group">
<input type="text" class="form-control" name="s" placeholder="Ara"><span class="input-group-btn"><button type="submit" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-search"></span></button></span>
</div>
</form>
<!-- Login/Logout -->
<div class="navbar-right">
<?php if (get_option('users_can_register')) : ?>
<a class="navbar-text" href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=register">Üye Ol</a>
<?php
if ( is_user_logged_in() ) {
echo '<a class="navbar-text" href="'.wp_logout_url( get_permalink() ).'" title="Logout">Logout</a>';
} else {
echo '<a class="navbar-text" href="'.wp_login_url( get_permalink() ).'" title="Login">Login</a>';
}
?>
<?php endif; ?>
</div>
</div><!--/.nav-collapse -->
</div><!-- /.container -->
</nav><!-- /.navbar -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment