jquery mobile - Custom data attributes in WordPress widget links -
i'm building mobile website wordpress , jquery mobile.
i create custom widget area appearing when user taps on button.
i links contained in widget area jqm buttons. should add attribute data-role="button" 'a' elements in widget.
is there way add custom attribute these 'a' elements functions.php?
by default, code of link in widget:
<h3 class="widget-title">categories</h3> <ul> <li class="cat-item cat-item-646"> <a title="some title" href="http://example.com/category/">category</a> </li> ...
i need add data-role attribute inside 'a' element:
<a title="some title" href="http://example.com/category/" data-role="button">category</a>
i know if wp api provides filter functions.php, or if possible in way php
to filter links , add data-role=button
them, use below code.
$('li.cat-item').find('a').each(function () { $(this).attr('data-role', 'button'); });
where .cat-item
class of list items.
Comments
Post a Comment