Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm writing one pager for my client. I made Child Theme from Twenty Thirteen. All is made on Bootstrap 3.2.0. I use tabs, accordion. And i also want to use jQuery Smooth Scroll plugin.

Unfortunately tabs and smooth scroll have a conflict. I resolved it by adding additional data-toogle to <li> element in HTML menu. Later on i have to switch from HTML menu to wp_nav_menu. And this is when the problem starts: default wp_nav_menu don't have ability to add unique data-toggle.

I know i can modify it in walker_nav_menu. What is more i use one Walker already - wp_bootstrap_navwalker.php https://github.com/twittem/wp-bootstrap-navwalker/blob/master/wp_bootstrap_navwalker.php

My problem: How can i modify wp_bootstrap_navwalker and add my unique data-toggle? I am begginer at php.

My previuos html menu:

     <div class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <li class="scroller"><a href="#oferta" data-toggle="elementscroll">oferta szkoleniowa</a></li>
        <li class="scroller"><a href="#informacje" data-toggle="elementscroll">informacje praktyczne</a></li>
        <li class="scroller"><a href="#logowanie" data-toggle="elementscroll">logowanie</a></li>
        <li class="scroller"><a href="#onas" data-toggle="elementscroll">o nas</a></li>
        <li class="scroller"><a href="#kontakt" data-toggle="elementscroll">kontakt</a></li>
      </ul>
    </div><!--/.nav-collapse -->

My new wp_nav_menu:

        <?php
        wp_nav_menu( array(
            'menu'              => 'Main menu',
            'container_class'   => 'navbar-collapse collapse',
            'menu_class'        => 'nav navbar-nav',
            'walker'            => new wp_bootstrap_navwalker())
        );
      ?>

Without data-toggle my jQuery Smooth Scroll doesn't work at all. Could you please please help me?

share|improve this question
    
Ok, i made it by myself :) I simply add one line with my unique data-toggle to wp_bootstrap_navwalker: $atts['data-toggle'] = 'elementscroll'; And it works :D –  Ewelina Jul 26 at 16:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.