Wordpress三级导航
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Wordpress三级导航相关的知识,希望对你有一定的参考价值。
This was for a customer.Basically it does this:
If a page has no children, it shows ... nothing,
if a page has a parent, it shows all other children of this parent (siblings) and the current page
if a page has a parent AND children (3rd level), it shows two separate menus, one with the siblings and current page and one with the children of the third level.
Maybe it helps someone.
<?php //Automatic Submenu global $wp_query; //If current page has no parent... { echo ""; } else //current page has parents { $me=$wp_query->post->ID; $children = wp_list_pages("title_li=&child_of=$me&echo=0"); if ($children) { $parent1 = $wp_query->post->post_parent; //show menu with current page's siblings echo "<ul class='submenus'>"; wp_list_pages("title_li=&child_of=$parent1&depth=1"); echo "</ul>"; $parent2 = $wp_query->post->ID; //show menu with current page's children echo "<ul class='subsubmenu'>"; wp_list_pages("title_li=&child_of=$parent2&depth=1"); echo "</ul>"; } else { $parent1 = $wp_query->post->post_parent; //show ONLY menu with current page's siblings echo "<ul class='submenus'>"; wp_list_pages("title_li=&child_of=$parent1&depth=1"); echo "</ul>"; } } ?>
以上是关于Wordpress三级导航的主要内容,如果未能解决你的问题,请参考以下文章