如何让一个页面的孩子的大孩子?
<?php
global $post;
$pages = get_children(array(
'post_parent' => $post->ID,
'numberposts' => -1
));
if ( $pages ):
$rows = array_chunk( $pages, ceil( count($pages) / 3 ) ); ?>
<div class="row">
<?php foreach ( $rows as $row ): ?>
<div class="col-sm-4">
<ul class="list-unstyled">
<?php foreach ( $row as $city ): ?>
<li><a href="<?= get_permalink( $city ) ?>"><?= $city->post_title ?></a></li>
<?php endforeach; ?>
</ul>
</div>
<?php endforeach; ?>
</div>
<?php endif;
通过使用wp_list_pages,我无法为列表创建列
答案 0 :(得分:0)
在父页面和子页面上显示子页面链接。
<?php
global $post;
// Use parent page if exists, else use current page
$child_of_value = ( $post->post_parent ? $post->post_parent : $post->ID );
// Depth of 2 if parent page, else depth of 1
$depth_value = ( $post->post_parent ? 2 : 1 );
// Build argument array
$wp_list_pages_args = array(
'child_of' => $child_of_value,
'depth' => $depth_value,
'title_li' => 'Sections',
'echo' => 0
);
// Now, output the result
wp_list_pages( $wp_list_pages_args );
?>