Adding a meta menu to .header-navigation-wrapper
-
Hey there,
I am using Chaplin with a responsive burger menu, but would like to add a few meta menu items to the header. Would that be possible via functions, or do I have to hard code it into the template?Cheers from Germany,
Very very fond of Chaplin, btw!!
-
Hi @mniggemann,
It isn’t possible with
functions.phpright now, but I’ll add a couple of actions toheader.phpin version 2.5.3 to make it easier to add output without copying over the entire file to a child theme. It should be live before the end of the day.The actions
chaplin_header_toggles_startandchaplin_header_toggles_endwill probably be good candidates, if you’re looking to add elements next to the navigation toggle.Happy to hear you like Chaplin!
— Anders
-
This reply was modified 5 years, 11 months ago by
Anders Norén.
Anders, that’s good news as well. I’ll see if I can manage to address the header via those actions tomorrow, or if I’d rather take the route of copying the header template.
Tack!
-MSorry to return to this ticket, but whereas I succeeded in registering my custom meta menu à la …
function chaplin_custom_menu() { register_nav_menu('chaplin-meta-menu',__( 'Meta Menü' )); } add_action( 'init', 'chaplin_custom_menu' );… I have no clue how to adress wp_nav_menu in functions.php to move my chaplin-meta-menu to its correct location within chaplin_header_toggles_start
(Cool to see how quick 5.2.3 was pushed out, btw)
@mniggemann No worries! Try this:
function chaplin_child_chaplin_header_toggles_start() { if ( has_nav_menu( 'chaplin-meta-menu' ) ) { wp_nav_menu( array( 'container' => '', 'depth' => 1, 'items_wrap' => '%3$s', 'theme_location' => 'chaplin-meta-menu', ) ); } } add_action( 'chaplin_header_toggles_start', 'chaplin_child_chaplin_header_toggles_start' );And yeah, it’s really nice that WordPress.org has a quick turnaround on pushing out updates.
Yay, there’s my menu.
Now can we make the whole WordPress ecosystem this cool?
Thanx!
So just for posterity’s sake or if anybody else wants to try this, I have since modified the code above like this, to add a ul and to make use of Chaplin’s styles for header menus.
(For morewp_nav_menuoptions, confer https://developer.wordpress.org/reference/functions/wp_nav_menu/)// Menu registration ... function chaplin_custom_menu() { register_nav_menu('chaplin-meta-menu',__( 'Meta Menu' )); } add_action( 'init', 'chaplin_custom_menu' ); // Menu positioning ... function chaplin_child_chaplin_header_toggles_start() { if ( has_nav_menu( 'chaplin-meta-menu' ) ) { wp_nav_menu( array( 'container' => 'div', 'container_class' => 'main-menu-alt-container', 'depth' => 1, 'items_wrap' => '<ul class="main-menu-alt dropdown-menu reset-list-style">%3$s</ul>', 'theme_location' => 'chaplin-meta-menu', ) ); } } add_action( 'chaplin_header_toggles_start', 'chaplin_child_chaplin_header_toggles_start' );Choose different class names for the ul if you want to use your own styles anyway. If you do use the above, make sure to set the ul to
display:block, as ist will be hidden by default otherwise.e.g.:
.header-toggles { align-items: center; display: flex; justify-content: flex-end; } .header-toggles .main-menu-alt-container { display: block; margin: 0 2rem 0 6rem; } -
This reply was modified 5 years, 11 months ago by
The topic ‘Adding a meta menu to .header-navigation-wrapper’ is closed to new replies.
