0

I want to remove the < ul >,< li > tags and add a < span > tag inside the < a > tag.

    <nav class="menu">
       <div class="menu-list">
          <a data-scroll="" href="#" class="">
             <span>Home</span>
          </a>
       </div>
    </nav>

Any help or explanation is appreciated.

This is where I am right now

class Walker_Nav_primary extends Walker_Nav_Menu
{

    function start_lvl( &$output)
    {   // ul
        $indent = str_repeat( &output, $depth );

    }

    function start_el(argument)
    {   // anything inside ul - opening tags
        # code...
    }

    function end_el(argument)
    {   // anything inside ul - closing tags
    # code...
    }

    function end_lvl(argument)
    {   // close ul
    # code...
    }

}
0

I just posted an answer to this here: How to create this custom menu walker?

Basically, you want your start_el and end_el to looks something like this:

function start_el(&$output, $item, $depth=0, $args=array()) {
   $output .= '<a href="#"><span>' . esc_attr($item->label);
}

function end_el(&$output, $item, $depth=0, $args=array()) {
    $output .= '</span></a>';
}
  • 1
    there is a syntax error on line 2. " . = " / / " .= " – Walid Omonos Dec 6 '16 at 4:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.