1

I have created a page that loads content from it's subpages.
The subpages contain post_thubnails. I use a foreach-loop to get the content of all pages.
I just can't get the images loaded.

<?php $args = array(
    'sort_order' => 'asc',
    'sort_column' => 'menu_order',
    'child_of' => $post->ID,
    'post_type' => 'page',
    'post_status' => 'publish'
    ); 
    $pages = get_pages($args); 
    foreach ($pages as $page){
        $file = get_post_meta ( $page->ID, '_wp_attached_file', true );
        echo $file;
        echo '
        <div class="full_width_parallax">
        <div class="wrap_1280">';
        echo $page->post_content;   
    echo '</div>    
    </div>';

    }

?>

Aside from the example code I have also tried the_post_thumbnail(); but no luck.

Any ideas?

2
  • You may also want to run your content through apply_filters( 'the_content', $page->post_content ); which will add paragraph tags and such to your post content where necessary.
    – Howdy_McGee
    Commented Jan 21, 2016 at 15:33
  • 1
    Thnx that helped! Commented Jan 21, 2016 at 15:39

1 Answer 1

2

Life can be simple:

Instead of the_post_thumbnail I should use get_the_post_thumbnail

echo get_the_post_thumbnail($page->ID)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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