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>    



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

Any ideas?

  • 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 Jan 21 '16 at 15:33
  • 1
    Thnx that helped! – Interactive Jan 21 '16 at 15:39

Life can be simple:

Instead of the_post_thumbnail I should use get_the_post_thumbnail

echo get_the_post_thumbnail($page->ID)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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