0

Just starting today, I started to convert my html site to Wordpress theme, and things seemed well until I got stock with the custom navigation menu.

I tried to convert the following code to wordpress navigation menu but I have no clue how to mix Material Design Lite (external framework) and wordpress.

<div class="mdl-layout__tab-bar mdl-js-ripple-effect mdl-color--primary-dark">
  <a href="#overview" class="mdl-layout__tab is-active">Overview</a>
  <a href="#features" class="mdl-layout__tab">Features</a>
  <a href="#features" class="mdl-layout__tab">Details</a>
  <a href="#features" class="mdl-layout__tab">Technology</a>
  <a href="#features" class="mdl-layout__tab">FAQ</a>
  <button class="mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--colored mdl-shadow--4dp mdl-color--accent" id="add">
    <i class="material-icons" role="presentation">add</i>
    <span class="visuallyhidden">Add</span>
  </button>
</div>

I just want to know if it's possible to create the same code above with

<?php wp_nav_menu( $args ); ?> 

Should I pass in some parameter ? or should I alter the dashboard ? Since I'm new to wordpress some help would be great ! I would love to hear from you !

1
  • 1
    Try searching for nav_walker in wordpress Commented Mar 15, 2016 at 7:23

1 Answer 1

1

Here's how you can do that

<div id="site-navigation" class="mdl-layout__tab-bar mdl-js-ripple-effect mdl-color--primary-dark">
<?php  
    $menuParameters = array(
        'container'       => false,
        'echo'            => false,
        'items_wrap'      => '%3$s',
        'depth'           => 0,
    );

    echo strip_tags( wp_nav_menu( $menuParameters ), '<a>' );
?>
<script type="text/javascript">
    $(document).ready(function(){
        $('#site-navigation a:first').addClass('mdl-navigation__link is_active');
        $('#site-navigation a').addClass('mdl-navigation__link');
    });
</script>
</div>          
Sign up to request clarification or add additional context in comments.

6 Comments

Thank you, but the javascript codes addClass seems to be not working. Im still in search of the solution but cannot find any answer. I've also been looking at nav_walker in wordpress but I find it still unclear.
have you added the jquery library of the latest version in your header?
Yes, it is added but it's not working. Should I add the Jquery CDN?
That depends, try to your local jquery if it is in the right path.
I tried, but sadly it doesn't work.. I'm lost right now.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.