php - How can I get the child pages of multiple page ID's in WordPress -
apologies if asked, did search , found nothing. i'm trying output kid pages of more 1 page id in same list , only output 6 of pages in assorted way. in other words, want kid pages of more 1 page , mix results in output. right i'm using:
<?php $nbpages = 6; $pages = wp_list_pages('title_li=&sort_column=post_name&child_of=1041'); $pages_arr = explode("\n", $pages); for($i=0;$i<$nbpages;$i++){ echo $pages_arr[$i]; } ?>
which fine getting kid pages of one id, can't figure out how add together array more one, mix results. help appreciated!
you should switch on using wp_query
, allows specify post_parent__in
parameter. parameter accepts array of page or post ids. note: need run wp 3.6 or higher this.
$so26932595_query = new wp_query( array( 'posts_per_page' => 4, 'post_type' => array( 'page' ), 'orderby' => 'rand', 'order' => 'none', 'post_parent__in' => array( 1043, 1045, 1047, 1049, 1591 ) ) ); while ( $so26932595_query->have_posts() ) : $so26932595_query->the_post(); echo '<a href="' . get_permalink() . '">' . get_the_title() . '</a>'; endwhile; wp_reset_postdata();
link: http://codex.wordpress.org/class_reference/wp_query
php wordpress
No comments:
Post a Comment