• Resolved mniggemann

    (@mniggemann)


    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!!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Theme Author Anders Norén

    (@anlino)

    Hi @mniggemann,

    It isn’t possible with functions.php right now, but I’ll add a couple of actions to header.php in 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_start and chaplin_header_toggles_end will 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 4 years, 6 months ago by Anders Norén.
    Thread Starter mniggemann

    (@mniggemann)

    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!
    -M

    Thread Starter mniggemann

    (@mniggemann)

    Sorry 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)

    Theme Author Anders Norén

    (@anlino)

    @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 www.ads-software.com has a quick turnaround on pushing out updates.

    Thread Starter mniggemann

    (@mniggemann)

    Yay, there’s my menu.

    Now can we make the whole WordPress ecosystem this cool?

    Thanx!

    Thread Starter mniggemann

    (@mniggemann)

    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 more wp_nav_menu options, confer https://developer.www.ads-software.com/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; }
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Adding a meta menu to .header-navigation-wrapper’ is closed to new replies.