How to get featured images of child pages?
-
I have a website that has several pages under the parent page of ‘Projects’. I would like the Projects page to automatically populate a list with the title, excerpt, and featured image of each project. I can do all of this with
get_pages
just fine, but don’t know how to properly fetch the featured image. Any hints?Page in question: https://tinyurl.com/3wp2oeb
Code:
<ul id="projects"> <?php $projects = get_pages( array('sort_column' => 'menu_order', 'sort_order' => 'ASC', 'child_of' => 46) ); if (!$projects) { echo "problem"; } else { foreach( $projects as $project ) { ?> <li> <img src="https://placehold.it/300x200" /> <h2><?php echo $project->post_title; ?></h2> <p><?php echo $project->post_excerpt; ?></p> </li> <?php } } ?> </ul>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘How to get featured images of child pages?’ is closed to new replies.