• Hi there!
    I´m trying to call this function on my page, since i want to show the sub-pages in post format, but it doesn´t seem to be working, it does nothing. Since I got this code from the Codex, I´m sure that the code is ok and I´m doing something wrong. The question is, should I call something else besides adding this to my page?

    <?php
    	$mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'desc' ) );
    
    	foreach( $mypages as $page ) {
    		$content = $page->post_content;
    		if ( ! $content ) // Check for empty page
    			continue;
    
    		$content = apply_filters( 'the_content', $content );
    	?>
    		<h2><a href="<?php echo get_page_link( $page->ID ); ?>"><?php echo $page->post_title; ?></a></h2>
    		<div class="entry"><?php echo $content; ?></div>
    	<?php
    	}
    ?>

    Thanks a lot!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter soppezzo

    (@soppezzo)

    Ok, I found this piece of code, which actually works! It is quite similar to the one I had above, but the other one didn´t work at all. So, Here I leave the right code below. What I need right now, is to show only the excerpt. Does anybody knows how to do this?

    <?php
    			 $mypages = get_pages('child_of='.$wp_query->post->ID.'&sort_column=post_date&sort_order=desc');
    			 $count = 0;
    			 foreach($mypages as $page)
    			 {
    			  $content = $page->post_content;
    			  if(!$content)
    			   continue;
    			  if($count >= 2)
    			   break;
    			  $count++;
    			  $content = apply_filters('the_content', $content);
    			 ?>
    			  <h2><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h2>
    			  <div class="entry"><?php echo $content ?></div>
    			 <?php
    			 }
    			?>

    Thanks!

    I think by replaceing $content = $page->post_content; with: $content = $page->post_excerpt; 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Displaying Child pages of the current page in post format is not working’ is closed to new replies.