I worked on wordpress and I found it via google. Then the only thing puzzling me is how to make the parent link to be allowed to expand the submenu instead of having the parent links be clickable..
jQuery(document).ready(function() {
//Hide the submenus
jQuery('.leftNav_Level2 ul li ul').hide();
//If its a page parent (based off wordpress), add the class "displayMe"
//This way the accordion will be opened up on the page you are on.
if (jQuery('.leftNav_Level2 ul li').hasClass("current_page_parent")) {
jQuery('.leftNav_Level2 .current_page_parent ul').addClass("displayMe");
jQuery('.leftNav_Level2 .current_page_ancestor > ul').attr('style','display:block');
jQuery('.leftNav_Level2 .current_page_parent > ul').attr('style','display:block');
}
jQuery('.leftNav_Level2 .current_page_item > ul').attr('style','display:block');
//When you click it, toggle
jQuery('.leftNav_Level2 ul li a').click(
function() {
//Onclick Remove the class dipslay me which is only display:block;
//This way they can close it if they click it or it will glitch
jQuery(this).next().next().slideToggle('slow').removeClass("displayMe");
//return false so the # doenst move view to the top of the page
if (jQuery(this).attr('href') == '#') { return false; }
//Close it all out
});
});
the wordpress template has:
<div class="leftNav_Level2">
<ul>
<?php wp_list_pages('title_li='); ?>
</ul>
</div><!--/leftNav_Level1-->
will appreciate help thank u
You are using too much javascript to solve the problem. I would say, use CSS for the styling (open/close submenus etc), a tutorial for that is here: http://wpguru.co.za/navigation/make-your-own-wordpress-drop-down-menu/
If you want the parent nodes stop navigating to the linked pages, you can use:
You can also take a look at the new menu since WP 3.0, more info here: http://bavotasan.com/2010/wordpress-3-checking-out-the-new-menu-system/