Using Get Pages for Page List
-
wp_list_pages doesn’t allow for you to display the author, so I am trying to get the same effect with get_pages.
However, the php code I’m using keeps getting one argument wrong.
At the end of the foreach loop I set the term $previous_page using page_title and then at the beginning of the next loop, that value disappears.
<?php $pages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc'); $count = 0; $ulcount = 0; $previous_parent = get_the_title($page->post_parent); $previous_page = $page->post_title; foreach($pages as $page) { $parent_page = get_the_title($page->post_parent); if($previous_parent != $parent_page && $previous_page = $parent_page) { echo '<br />'; echo $previous_page; echo ' (previous_page) equals '; echo $parent_page; echo ' (parent_page)<ul>'; $ulcount++; echo $ulcount; } $content = $page->post_content; if(!$content) continue; $count++; $content = apply_filters('the_content', $content); ?> <li> <a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a> (parent: <?php $parent_title = get_the_title($page->post_parent); echo $parent_title; ?>)</li> <?php if($previous_parent != $parent_page && $previous_page != $parent_page) while($ulcount > 0) { echo '</ul>'; $ulcount--; } $previous_parent = get_the_title($page->post_parent); $previous_page = $page->post_title; echo 'previous_page = '; echo $previous_page; } ?>The page is here http://www.wheeloftimerp.net/members/
Let me know if you have any progress.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Using Get Pages for Page List’ is closed to new replies.