我在一个WordPress站点上有一个侧边栏菜单,可以简单地输出该父站点下的所有子页面。我正在尝试突出显示(或者希望添加一个箭头)当前选择的子页面。由于我有限的PHP经验,我遇到了困难,无法弄清楚如何做到这一点。
任何帮助都将不胜感激。相关代码如下:
<?php
/* if the current pages has a parent, i.e. we are on a subpage */
if($post->post_parent){
/* $children = wp_list_pages("title_li=&include=".$post->post_parent."&echo=0"); // list the parent page */
$children .= wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); // append the list of children pages to the same $children variable
}
/* else if the current page does not have a parent, i.e. this is a top level page */
else {
//$children = wp_list_pages("title_li=&include=".$post->ID."&echo=0"); // include the parent page as well
$children .= wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&"); // form a list of the children of the current page
}
/* if we ended up with any pages from the queries above */
if ($children) { ?>
<ul class="submenu">
<?php echo $children; /*print list of pages*/ ?>
</ul>
<?php } ?>
我假设它应该在输出部分,但我只是不知道如何定位正在浏览的当前子页面并相应地突出显示它。
https://stackoverflow.com/questions/56674986
复制相似问题