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...
}
}
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...
}
}
Share
Improve this question
asked Dec 5, 2016 at 18:27
Mahade WalidMahade Walid
1451 silver badge7 bronze badges
1
- Have a read through this: code.tutsplus/tutorials/… – montrealist Commented Dec 5, 2016 at 18:52
1 Answer
Reset to default 1I 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>';
}