html - Wordpress Walker class for wp_list_pages -
I am using wp_list_pages to create navigating pages in my site.
In a few pages, I need a dropdown menu in the nav to show hair pages.
I am using Bootstrap to create dropdown menus.
Class me to use the bootstrap
I think the best way to add these classes is using the custom walker class.
How do I write this custom class? Add the sections I need.
Output HTML
& lt; Ul class = "" & gt; & Lt; Li class = "page_item page-item-6-current_page_item" & gt; & Lt; A href = "/" & gt; Home & lt; / A & gt; & Lt; / Li & gt; & Lt; Li class = "page_item page-item-6-current_page_item" & gt; & Lt; A href = "/" & gt; Profile & lt; / A & gt; & Lt; / Li & gt; & Lt; Li class = "page_item page-item-8page_item_html_school" & gt; & Lt; A href = "" & gt; Products & amp; # 038; Service & lt; / A & gt; & Lt; Ul class = 'children' & gt; & Lt; Li class = "page_item page-item-17" & gt; & Lt; A href = "" & gt; Buying & lt; / A & gt; & Lt; / Li & gt; & Lt; Li class = "page_image page-item -19" & gt; & Lt; A href = "" & gt; Selling & lt; / A & gt; & Lt; / Li & gt; & Lt; Li class = "page_item page-item -23" & gt; & Lt; A href = "" & gt; Management & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Li & gt; & Lt; / Ul & gt;
I want html
Use jquery:
$ ( "Page_item_has_children"). Each (function () {$ (this) .addClass ("dropdown");}); $ ("Li.page_item_has_children" gt; a). $ (This) .addClass ("dropdown-toggle"); $ (this) .attr ("data-toggle", "dropdown"); $ (this) .next (). AddClass (" drop down menu");});
Comments
Post a Comment