Add page ID to walker function start_lvl
-
Hi,
I am trying to make the Twitter Bootstrap accordion menu to work in WordPress. Therefore I need to get the page ID in my walker function start_lvl to put it in the
<ul>
tag so it can get triggered.This is what I am trying to achieve in HTML:
<li id="" class="accordion-group"> <a href="#collapsePAGEID" class="active" data-toggle="collapse" data-parent="#menu">Menu Option 1</a> <ul id="collapsePAGEID" class="accordion-body in collapse"> <li id="" class="active"> <a href="" class="">Submenu Option 1</a> etc... </li> </ul> </li>
I used start_el to put the page ID in
<a href="#collapsePAGEID">
. But I can’t use start_lvl in the same way.My code so far for start_lvl:
// add classes to ul sub-menus function start_lvl( &$output, $depth, $item ) { // depth dependent classes $indent = ( $depth > 0 ? str_repeat( "\t", $depth ) : '' ); // code indent $display_depth = ( $depth + 1); // because it counts the first submenu as 0 $pgid = ; //How to get the page ID? $ids = array( 'collapse' . $pgid ); $id_name = implode( ' ', $ids ); // build html $output .= "\n" . $indent . '<ul id="' . $id_name . '" >' . "\n"; }
Any clues?? Much appreciated!
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Add page ID to walker function start_lvl’ is closed to new replies.