[resolved] Landing Page - Using Featured Image of Child Pages (3 posts)

  1. Richard Saunders
    Posted 4 years ago #

    Good Morning,

    I'm trying to create a page template that outputs the page content, followed by the Title / Excerpt / Featured Image of any child pages of the parent.

    I've successfully generated a template that outputs the content from the child pages that I require, however I'm unable to output 'the_content' of the parent page.

    I've provided the template code in a pastebin.


    As 'the_title' of the parent page is output, i'd have expected 'the_content' on line 16 to output the parent page content.

    Any help anyone could provide would be greatly appreciated.

    Kindest Regards


  2. Ross Hanney
    Posted 4 years ago #

    Hi Richard,

    This is because you haven't set up The Loop for the template.

    I've posted a modified version of your code here. Notice the main loop on line 11, and specifically the call to the_post(), which sets up the post (or in this case, page) data so that functions such as the_content() can be called.

    You could probably get away without using The Loop, and only calling the_post(), but it's generally considered good practice to use The Loop.

  3. Richard Saunders
    Posted 4 years ago #


    Not sure how I managed to miss that. Thanks for your quick response, this has done the trick.



Topic Closed

This topic has been closed to new replies.

About this Topic