我仍然在愚弄这个愚蠢的导航菜单。这个想法是,当你第一次访问页面时,会列出顶级页面,当其中一个页面被点击时,第二级菜单出现在其下面,并显示所有选定页面的子页面,当点击其中一个页面时,所有页面所选二级页面的三级页面显示在二级页面下方。3级WordPress的导航问题
我试图用各种方式来完成这个任务,我甚至试图让一个会话存储来记住一些部分,但是我无法找到一个好的解决方案。
这是我迄今所做的:
<?php
wp_nav_menu(array(
'sort_column' => 'menu_order',
'theme_location' => 'primary-menu'
));// Prints the primary top level menu
$level = count($post->ancestors);
echo $level;// Just for testing purposes
if ($post->post_parent){
$children = wp_list_pages("title_li=&child_of=" . $post->post_parent . "&echo=0&depth=1");
$grandchildren = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
}
else{
$children = wp_list_pages("title_li=&child_of=" . $post->ID . "&echo=0&depth=1");
}
if ($children) {
echo $children;
}
if ($grandchildren){
echo $grandchildren;
}
?>
这里是我遇到的问题。它是一种方式,所以如果我点击顶层第二层出现,如果我点击第二层,第三层出现,但是当我点击第三层时,第二层消失。
这让我疯狂!我已经花了一天时间在这现在阅读所有关于get_post get_children等等等等等等
感谢,
Ç
你可以使用jquery mega菜单插件为这个和所有的事情进行得很好 – 2013-05-10 04:02:18