2017-01-04 34 views
0

我需要顯示父頁面的所有孩子和孫子,但我想要自定義輸出而不是wp_list_pages()給出的標準輸出。WP_LIST_PAGES使用WP_QUERY定製輸出

<?php 
    wp_list_pages(array(
     'title_li' => '', 
     'child_of' => $post->ID 
    )); 
?> 

我設法顯示到兒童網頁,但使用這種沒有孫子:

<?php 
    $args = array(
     'post_type' => 'page', 
     'post_parent' => $post->ID, 
     'order' => 'ASC' 
    ); 
    $the_query = new WP_Query($args); 
?> 

<?php if ($the_query->have_posts()) : ?> 
    <?php while ($the_query->have_posts()) : $the_query->the_post(); ?> 
     <li> 
      <a href="<?php the_permalink(); ?>" rel="post-<?php the_ID(); ?>" <?php post_class(); ?>> 
       <div class="table"> 
        <div class="table-cell"> 
         <span></span> 
         <h3><?php the_title(); ?></h3> 
        </div> 
       </div> 
      </a> 
     </li> 
    <?php endwhile; ?> 
<?php endif; ?> 

關於如何擴展該代碼顯示在子頁面就像當初wp_list_pages孫子任何建議() ?

謝謝!

回答

0

我設法找到一個很好的方式來擴展wp_list_pages();

<?php 
    wp_list_pages(array(
     'title_li' => '', 
     'child_of' => $post->ID, 
     'link_before' => '<span></span><h3>', 
     'link_after' => '</h3>' 
    )); 
?> 

不正是我想要的,喜歡自定義列表,並添加一些額外的東西,但是這會工作得很好了我所需要的。