首页 > 解决方案 > 如何在 wordpress 子菜单中检索自定义链接?

问题描述

我用 wp_nav_menu 创建了一个 wordpress 菜单。如何让我的子菜单(我的子页面右侧的布局)回显该页面的主导航(因此它显示您所在页面的子链接)并包含自定义链接?

目前我有这个确实显示了父页面的所有子页面,但完全忽略了我在 wp_nav_menu 导航中添加的任何自定义链接,我理解这是因为它正在查看页面层次结构:

<body>
<!--sub menu side bar -->
        <?php 
        $PageArray = get_pages(array(
            'child_of' => get_the_ID()
        ));

        if ($theParent or $PageArray) { ?>
        <div class="page-links">
          <h2 class="page-links__title"><a href="<?php echo get_permalink($theParent); ?>"><?php echo get_the_title($theParent); ?></a></h2>
          <div class="wave_page-links"></div>
          <ul class="min-list">
            <?php
                if ($theParent) {
                    $findChildrenOf = $theParent;
                } else {
                    $findChildrenOf = get_the_ID();
                }
                wp_list_pages(array(
                    'title_li' => NULL,
                    'child_of' => $findChildrenOf,
                    'sort_column' => 'menu_order', /*change page order in page attributes*/
                ));
            ?>
          </ul>
        </div>
        <?php } ?>

标签: phphtmlwordpressnavigation

解决方案


推荐阅读