Advertisement
Guest User

Untitled

a guest
Jul 1st, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. <?php
  2. $args = array(
  3. 'post_type' => 'posts',
  4. 'posts_per_page' => 99,
  5. 'orderby' => 'parent',
  6. 'order' => 'ASC'
  7. );
  8. $posts = get_posts( $args );
  9. foreach ( $posts as $post ) {
  10. $childargs = array(
  11. 'post_type' => 'posts',
  12. 'child_of' => $post->ID
  13. );
  14. $children = get_pages( $childargs );
  15. $childcount = count( $children );
  16. if( $childcount == 0 ) {
  17. $title = get_the_title( $post->ID );
  18. echo '<li>' . $title . '</li>';
  19. }
  20. } // close foreach
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement