I am making a dynamic wordpress links in navigation bar using nav_walker. How can i implement center something like this in wordpress nav_walker:
+-----------------------------+-----------+------------------------------+
+---------------HOME--ABOUT---|-LOGO HERE-|---CONTACT--PROFILE-----------+
+-----------------------------+-----------+------------------------------+
How can i do that or something provide me jsfiddle to come up with that please. Is it two nav_walker function for left and right navigation? how can i insert the navbar brand in center? can anyone give me structure. thanks.
my code:
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-brand navbar-center">
</div>
<?php wp_nav_menu(array(
'menu' => 'primary-1',
'theme_location' => 'primary-1',
'depth' => 2,
'container' => 'div',
'container_class' => 'collapse navbar-collapse navbar-center',
'container_id' => 'bs-example-navbar-collapse-1',
'menu_class' => 'nav navbar-nav',
'fallback_cb' => 'wp_bootstrap_navwalker::fallback',
'walker' => new wp_bootstrap_navwalker()
));
?>
</nav>
Ok try using the below markup to achieve what you are looking for, you also need to tweak a little of CSS to override the bootstrap's default styles.
HTML
The CSS which achieves what you want(make sure this overrides the default bootstrap styles)
Codepen here
A while ago I was looking for the exact same thing and came across this pen. props to Bryan Willis
Bootstrap 3 Headers Look at last example !
HTML
CSS
It can by suprisingly simple if you have same amount of items on left and on right. Just create a list, put the logo in the middle and do
text-align: center
. See here: https://jsfiddle.net/DTcHh/26132/The trouble starts when the left and right are even slightly uneven. I suggest creating two lists, each for half of the screen. They will be aligned towards the center and leave a space in the center for the logo.
Check it out here: https://jsfiddle.net/DTcHh/26133/
html:
css:
As for how to implement this with wordpress, I believe you will have to get rid of the navwalker plugin. Just create two menus in wordpress:
left-primary
andright-primary
. Then just iterate them withwp_get_nav_menu_items('left-primary')
and build the menu as I suggested. Here is the php code without the nav-walker: