Advertisement
lberelson

custom3 - function child or no child pages

Jan 22nd, 2014
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1.  //attempt creating a test child page function
  2. <?php function testchildren () {
  3.     $children = get_pages('child_of='.$post->ID);
  4.     if( count( $children ) != 0 )  {
  5.         echo 'has NO children';
  6.         return $nochildren;
  7.         }
  8.     else
  9.         {
  10.         echo 'has children';
  11.         return $haschildren;
  12.         }
  13. }
  14. ?>
  15.  
  16.  
  17. <!-- basic loop -->
  18. <?php if (have_posts()) : while (have_posts()) : the_post() ; ?>
  19. <h2>
  20.     <?php $parent_title = get_the_title($post->post_parent); echo $parent_title; ?>
  21. </h2>
  22.  
  23. <?php testchildren (); ?>
  24.  
  25.      <h1 style="margin-bottom:12px"><?php the_title(); ?></h1>
  26.  
  27.    
  28.     <?php the_content(); ?>
  29. <?php endwhile; endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement