php - 如何在 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 } ?>
解决方案
推荐阅读
- reactjs - 如何从 React 中的异步函数获取数据
- javascript - TypeError:无法读取未定义的属性“hasPermission”
- angular - 我必须使用什么网络服务器来部署 Angular 应用程序?
- api - Plaid 或 Flinks,在加拿大(以及未来的美国)哪个是更好的开放银行数据 API?
- c++ - 物理内存地址和指针地址不相同
- python - 为什么 np.random.default_rng().permutation(n) 优于原始的 np.random.permutation(n)?
- c++ - C ++传递给函数会将对象变量变成垃圾
- python - 为什么json输出这么小?
- javascript - 找不到模块:内部/模块/cjs/loader.js:969
- linux - printk() 消息未出现在控制台中