WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know how to display content from one page on another page. Here is the code I use to display the last three video-titles, submitted to my video-page, on another page (using Advanced Custom Fields for the content)

$other_page = 5;
<?php if(get_field('video', $other_page)): $count = 0; ?>
<?php while (the_repeater_field('video', $other_page)): $count++; ?>
<?php the_sub_field('video_title'); ?>      
<?php if($count==3) break; ?>   
<?php endwhile; ?>
<?php endif; ?> 

But what I want to do is to display content from the last three video-subpages, and not just the content displayed on the video page itself. Does anyone know how to do this? :)

share|improve this question
up vote 0 down vote accepted

you can use the number param to limit the number of pages you want and get the custom field in the foreach loop :) (child of = your parent page, or the current page)

$mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'desc', 'number' => 3, ) );

foreach( $mypages as $page ) {      
    $content = $page->post_content;
    $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>


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.