Wordpress:显示第四个导航级别的方式?

Wordpress:显示第四个导航级别的方式?,wordpress,Wordpress,当我在第三层时,wordpress中有没有办法只显示第四层导航 谢谢 试试这个: <?php if($post->post_parent) { $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); $titlenamer = get_the_title($post->post_parent); } else { $childre

当我在第三层时,wordpress中有没有办法只显示第四层导航

谢谢

试试这个:

<?php
  if($post->post_parent) {
  $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
  $titlenamer = get_the_title($post->post_parent);
  }

  else {
  $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
  $titlenamer = get_the_title($post->ID);
  }
  if ($children) { ?>

  <h2> <?php echo $titlenamer; ?> </h2>
  <ul>
  <?php echo $children; ?>
  </ul>

<?php } ?>

此代码将显示当前页面的所有子页面。因此,当您处于级别3时,它将显示级别4子页面(如果存在)


您可以尝试此功能:

function getPages($pid=0) {
    global $wpdb;
    $pages = $wpdb->get_results($sql = "
        SELECT *
        FROM $wpdb->posts
        WHERE
            post_type = 'page' &&
            post_status = 'publish' &&
            post_parent = $pid
        ORDER BY menu_order
    ");
    return $pages;
}

$pid是第三级导航页面id中的父级id。

是否要在主菜单或侧边栏或页面的某个位置显示第四级导航?我想在内容区域显示第四级,而不是在主页导航中!