简体   繁体   中英

Unable to implement custom Navigation menu in Wordpress Theme

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 !

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>          

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM