php WP-子菜单

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php WP-子菜单相关的知识,希望对你有一定的参考价值。

// Get Top Parent Page (in functions.php)
function get_top_parent() {
   global $post;
   if($post->post_parent) {
      $ancestors = array_reverse(get_post_ancestors($post->ID));
      return $ancestors[0];
   }
   return $post->ID;
}

// Get submenu items (insert in page submenu)
$args = array(
   'child_of' => get_top_parent(),
   'title_li' => ''
);

wp_list_pages($args);

以上是关于php WP-子菜单的主要内容,如果未能解决你的问题,请参考以下文章

在折叠移动显示所有引导子菜单为打开

wp_nav_menu walker 类子菜单仅显示在父页面上

如何在 WordPress 中使用 wp_get_nav_menu_items 生成自定义菜单/子菜单系统?

Wordpress 3.5 - 如何仅使用 wp_nav_menu 显示父级的子菜单?

在 wp 导航菜单中将父页面和子页面包装在单独的 ul 中

scss 来自wp_nav_menu的补充工具栏/小工具子菜单