首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在自定义侧边栏菜单上突出显示当前子页面?

如何在自定义侧边栏菜单上突出显示当前子页面?
EN

Stack Overflow用户
提问于 2019-06-20 03:56:22
回答 1查看 76关注 0票数 0

我在一个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 } ?>

我假设它应该在输出部分,但我只是不知道如何定位正在浏览的当前子页面并相应地突出显示它。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56674986

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档