I’ am using bootstrap 3. I’ don’t know if its possible in WordPress to add the class on function wp_list_pages on its children ul. I know it possible with jQuery.
This is what I currently have
<ul class="nav navbar-nav dropdown" role="menu" aria-labelledby="dLabel">
<?php
$args = array(
'authors' => '',
'child_of' => 0,
'date_format' => get_option('date_format'),
'depth' => 2,
'echo' => 1,
'exclude' => '5, 141, 143, 145',
'include' => '',
'link_after' => '',
'link_before' => '',
'post_type' => 'page',
'post_status' => 'publish',
'show_date' => '',
'sort_column' => 'menu_order',
'title_li' => '',
'walker' => ''
);
?>
<?php wp_list_pages( $args ); ?>
</ul>
This is a dropdown menu, so WordPress adds a class children into its ul, but can I add bootstrap class dropdown into that children ul.
You need to create a custom walker to change the child
<ul>
class. There’s no filter inside the default page walker to change the classes that are applied.You don’t need to include so many arguments for
wp_list_pages
by the way. Only the ones you change.Here’s how I’d do it:
Add to functions.php –
Then replace your existing call to
wp_list_pages()
with:Okay, still didn’t find what I was looking for but I found a work around without using jQuery only had to paste in the code of class dropdown-menu into my css style, thats it. Works!
CSS