我正在尝试循环所有的页面,这是一个伟大的曾孙id 101,但我不能得到这个工作。对问题可能是什么有什么建议吗?
$args = array(
'post_type' => 'page',
'page_id' => $greatGreatGrandChild-of-101, ?
'posts_per_page' => -1
);
最后我是这样做的。此列表列出了所有曾孙或id为101的页面。
<ul>
<?php
$postid = 101;
$args = array(
'post_type' => 'page',
'post_status' => 'publish',
'orderby' => 'rand',
'posts_per_page' => -1,
'post_parent' => $postid
);
$child_level = get_posts($args);
if($child_level) :
foreach($child_level as $child_page) :
$chgs = array(
'post_type' => 'page',
'post_status' => 'publish',
'orderby' => 'rand',
'posts_per_page' => -1,
'post_parent' => $child_page->ID
);
$grandchild_level = get_posts( $chgs );
if($grandchild_level) :
foreach($grandchild_level as $grandchild_level) :
$grgs = array(
'post_type' => 'page',
'post_status' => 'publish',
'orderby' => 'rand',
'posts_per_page' => -1,
'post_parent' => $grandchild_level->ID
);
$greatgrandchild_level = get_posts( $grgs );
if($greatgrandchild_level) :
foreach ($greatgrandchild_level as $greatgrandchild_level) :
$ggrgs = array(
'post_type' => 'page',
'post_status' => 'publish',
'orderby' => 'rand',
'posts_per_page' => -1,
'post_parent' => $greatgrandchild_level->ID
);
$greatgreatgrandchild_level = get_posts( $ggrgs );
$my_query = new WP_Query($ggrgs);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
<?php endwhile;
}
wp_reset_query();
endforeach;
endif;
endforeach;
endif;
endforeach;
endif;
?>
</ul>