deekay
June 30, 2014, 8:35am
#1
I want to add a custom Menu to the footer. It should be a copy of the primary menu without dropdowns. Every menu entry should be an UL.
Here is the static HTML:
<div class="row">
<div class="col-sm-12">
<div class="col-sm-3">
<ul class="list-unstyled">
<li>Category #1</li>
<li><a href="#">Item #1</a></li>
<li><a href="#">Item #2</a></li>
<li><a href="#">Item #3</a></li>
<li><a href="#">Item #4</a></li>
</ul>
</div>
<div class="col-sm-3">
<ul class="list-unstyled">
<li>Category #2</li>
<li><a href="#">Item #1</a></li>
<li><a href="#">Item #2</a></li>
<li><a href="#">Item #3</a></li>
<li><a href="#">Item #4</a></li>
</ul>
</div>
</div>
</div>
How am i going to do implement this dynamically? I created a custom menu and added it to the footer. I guess i have to write a custom query at this point but i have no idea how to do that the roots way…
Have a look at this post: Custom Footer Menu
You can achieve this with a custom walker.
deekay
June 30, 2014, 1:09pm
#3
Thanks alot, i copy-pasta’d your solution and it worked quite well. What would i need to change if i want the parent item not to be a link?
Like in:
Products
Product #1
Product #2
“Products” should not be wrapped in an a tag…
cfx
June 30, 2014, 1:50pm
#4
You should get the result you want by replacing this:
if ($item->is_dropdown && ($depth === 0)) {
$item_html = str_replace('<a', '<a class="dropdown-toggle" data-toggle="dropdown" data-target="#"', $item_html);
$item_html = str_replace('</a>', ' <b class="caret"></b></a>', $item_html);
}
With this:
if ($item->is_dropdown && ($depth === 0)) {
$item_html = preg_replace('/<a[^>]*>(.*)<\/a>/iU', '$1', $item_html);
}
deekay
July 1, 2014, 8:23am
#5
You mean my starter question or the followup? Cause the followup doesnt work with your idea. Sorry to bother you but this walker-stuff is really new to me…
mirago
July 1, 2014, 11:02am
#6
Can’t you just create a custom menu and add it to the footer as a widget?
cfx
July 1, 2014, 1:32pm
#7
Please paste the entire walker code you’re using and the function you use to call it.