1

私はWordpressでこのようなページ構造を持っています:

  • メインページ
    • メインページの子
      • メインページの孫
      • メインページの孫
      • メインページの孫
      • メインページの孫
    • メインページの子
      • メインページの孫
      • メインページの孫
      • メインページの孫
      • メインページの孫

等...

メインページの各子ページ/孫ページのタイトル/コンテンツを表示したいだけです。誰か助けてください。

4

1 に答える 1

0

wp_list_pages()関数を使用し、最上位の祖先とレベルを指定する必要があります2

<?php 

  $postid = get_the_ID();
  $topid = get_top_ancestor($postid); 

  $args = array(
          'depth'        => 2,
          'show_date'    => '',
          'date_format'  => get_option('date_format'),
          'child_of'     => $topid,
          'exclude'      => '',
          'include'      => '',
          'title_li'     => '',
          'echo'         => 1,
          'authors'      => '',
          'sort_order'   => 'ASC',
          'link_before'  => '',
          'link_after'   => '',
          'walker'       => '',
          'post_type'    => 'page',
          'post_status'  => 'publish' 
  ); ?>
<ul>
  <?php wp_list_pages( $args ); ?>
</ul>
于 2012-08-28T09:02:43.733 に答える