Skip to content

Instantly share code, notes, and snippets.

@peksi
Last active February 8, 2021 10:51
Show Gist options
  • Save peksi/67f240ec342c4b143e10034dcc2aaf47 to your computer and use it in GitHub Desktop.
Save peksi/67f240ec342c4b143e10034dcc2aaf47 to your computer and use it in GitHub Desktop.
Bootstrap dropdown navbar implementation for Wordpress Timber plugin.
{# Bootstrap dropdown navbar for Wordpress #}
<ul class="nav navbar-nav">
{% for item in menu %}
{% if (item.get_children) %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{item.title}} <span class="caret"></span></a>
<ul class="dropdown-menu">
{% for subitem in item.get_children %}
<li><a href="{{subitem.get_link}}">
<span data-letters="{{subitem.title}}">{{subitem.title}}</span>
</a></li>
{% endfor %}
</ul>
</li>
{% else %}
<li class="{{item.classes | join(' ')}}">
<a href="{{item.get_link}}">
<span data-letters="{{item.title}}">{{item.title}}</span>
</a>
{% include "menu.twig" with {'menu': item.get_children} %}
</li>
{% endif %}
{% endfor %}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment