Build a WordPress and Bootstrap ready Menu

An outstanding work from rootstheme. These functions drop all those post and menu classes, set the new walker as default WordPress navigation walker and also converts the code to bootstrap ready navbars. One of my favorite snippets and used on every site I build.

/**
 * Snippet Name: Build a WordPress and Bootstrap ready Menu
 * Snippet URL: https://www.wpcustoms.net/snippets/build-a-wordpress-and-bootstrap-ready-menu/
 */
  /**
 * Cleaner walker for wp_nav_menu()
 *
 * Walker_Nav_Menu (WordPress default) example output:
 *   
  • Home
  • *

  • Sample Page*
    * Roots_Nav_Walker example output:
    *
  • *

    */
    class Roots_Nav_Walker extends Walker_Nav_Menu {
    function check_current($classes) {
    return preg_match(‘/(current[-_])|active|dropdown/’, $classes);
    }

    function start_lvl(&$output, $depth = 0, $args = array()) {
    $output .= “n

    0 0 vote
    Article Rating
    Subscribe
    Notify of
    guest
    0 Comments
    Inline Feedbacks
    View all comments
    0
    Would love your thoughts, please comment.x
    ()
    x