Wordpress nav customize


Wordpress nav customize


require get_template_directory() . '/assets/bootstrap-navwalker.php';

function header_menu_li_classes($classes, $item, $args) {
  if($args->theme_location == 'menu-1') {
    $classes[0] = 'st-Nav_Item st-Nav_Item-menu';
  }
  return $classes;
}
add_filter('nav_menu_css_class', 'header_menu_li_classes', 1, 3);

function header_menu_a_classes($ulclass) {
   $a = preg_replace('/<a /', '<div class="st-Nav_ItemInner"><a class="sw-FF-helvetica-neue st-Nav_Link"', $ulclass);
   return preg_replace('/<\/a>/', '</a></div>', $a);
}
add_filter('wp_nav_menu','header_menu_a_classes');

View file

wp_nav_menu( array(
'theme_location' => 'menu-1',
'menu_id'        => 'primary-menu',
'container'      => false, //'div', 
'container_class' => 'menu-{menu slug}-container', 

'container_id'    => ,
'depth'          => 2,
'menu_class'     => 'st-Nav_List',
            
'walker'         => new Bootstrap_NavWalker(), // This controls the display of the Bootstrap Navbar
'fallback_cb'    => 'Bootstrap_NavWalker::fallback', // For menu fallback
'before'          => ,
'after'           => ,
'link_before'     => ,
'link_after'      => ,
'items_wrap'      => '<ul id=\"%1$s\" class=\"%2$s\">%3$s</ul>',

) );

Share this

Related Posts

Previous
Next Post »