最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

menus - Nav_walker add id to dropdown ul

programmeradmin3浏览0评论

I'm trying to add an id to the dropdown ul in bootstrap navwalker. So at the moment this is what I've got:

        <ul id="menu-primary-menu" class="list-unstyled components">
            <li id="menu-item-8" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-8 dropdown">
                <a title="Collapse 1" href="#8" data-toggle="collapse" aria-expanded="false">Collapse 1</a>
                <ul role="menu" class="collapse list-unstyled">
                    <li id="menu-item-6" class="menu-item menu-item-type-post_type menu-item-object-post menu-item-6"><a title="Collapse 1 menu item" href="">Collapse 1 menu item</a>
                    </li>
                </ul>
            </li>
        </ul>

And this is what I want

        <ul id="menu-primary-menu" class="list-unstyled components">
            <li id="menu-item-8" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-8 dropdown">
                <a title="Collapse 1" href="#8" data-toggle="collapse" aria-expanded="false">Collapse 1</a>
                <ul role="menu" class="collapse list-unstyled" id="8">
                    <li id="menu-item-6" class="menu-item menu-item-type-post_type menu-item-object-post menu-item-6"><a title="Collapse 1 menu item" href="">Collapse 1 menu item</a>
                    </li>
                </ul>
            </li>
        </ul>

Add id in here:

<ul role="menu" class="collapse list-unstyled" id="8">

So in I need to add the id which would be the same as the parent menu-item. I'm assuming I need to edit this line in bootstrap navwalker:

//default
        $output .= "\n$indent<ul role=\"menu\" class=\" dropdown-menu\">\n";

//my edit
        $output .= "\n$indent<ul role=\"menu\" class=\"collapse list-unstyled\" id=\"".??."\">\n";

But I have no idea where I can get this ID from...

Thank you in advance for your help :)

发布评论

评论列表(0)

  1. 暂无评论