In WordPress, there is default Archives widget that displays a form select with the list of monthly archives and on change
executes:
document.location.href=this.options[this.selectedIndex].value;
I need the same functionality but styled like a Bootstrap dropbdown
<div class="btn-group dropdown">
<button class="btn btn-link">Dropdown Button</button>
<button class="btn dropdown-toggle btn-large" data-toggle="dropdown"><span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="">Link</a></li>
<li><a href="">Link</a></li>
<li><a href="">Link</a></li>
</ul>
</div>
How can I achieve this?
Is there any class that I could add to the select, so that I get the Bootstrap dropdown style along with the same functionality?
There’s no way of modifying the output for that widget. You have to copy the whole
WP_Widgets_Archives
and create your own widget.See the Widgets_API and this old, but still valid article: The complete guide to creating widgets in WordPress 2.8.
You’ll have to place your code in this block:
Note the format
html
forwp_get_archives
, this produces a<li>
list.If you are using SASS