Display subpages with child of
-
Hi!
I’m trying to display the subpages on a page and I use the code below. It works perfectly, but I need it changed a little.<?php $page_ids = array(); $subpages = get_pages('depth=4&child_of='.$post->ID.'&sort_column=post_title'); if($subpages)foreach($subpages as $subpage) { $page_ids[] = $subpage->ID; } $subpages = new WP_Query( array( 'post_type' => 'page', 'post__in' => $page_ids, 'orderby' => 'title', 'paged' => get_query_var('paged') )); $count = 0; if($page_ids && $subpages->have_posts()) : ?> <ul class="product_list"> <?php while($subpages->have_posts()) : $subpages->the_post(); ?> <li> <div class="product_layout"> <div class="thumb1"><a href="<?php echo get_page_link($post->ID) ?>"><?php echo get_the_post_thumbnail($post->ID, 'thumbnail'); ?></a> <a href="<?php echo get_page_link($post->ID) ?>" title="<?php echo $post->post_title ?>"><?php $thetitle=$post->post_title; $getlength = strlen($thetitle); $thelength = 18; echo substr($thetitle, 0, $thelength); if ($getlength > $thelength) echo "..."; ?></a></div> <div class="bottom"></div> </li> <?php endwhile; ?> </ul>
At some point I have Page1 with the SubPage1 whom has a SubSubPage1 with a SubSubSubPage1 and the code displays all of them,
I want it to show me only the SubSubSubPage1 and I tried using
depth but it doesn’t work. I used it like that:<?php $page_ids = array(); $subpages = get_pages('depth=4&child_of='.$post->ID.'&sort_column=post_title'); if($subpages)foreach($subpages as $subpage) { $page_ids[] = $subpage->ID; } $subpages = new WP_Query( array( 'post_type' => 'page', 'post__in' => $page_ids, 'orderby' => 'title', 'paged' => get_query_var('paged') )); $count = 0; if($page_ids && $subpages->have_posts()) : ?>
Can someone help me?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Display subpages with child of’ is closed to new replies.