获取子页面特色图片源URL


Wordpress - get a child pages Featured Image source URL

我在WordPress站点的父页面上有下面的代码。该页从子页中提取内容,以摘要格式显示在其上。我缺少的是如何从子页面拉特色图像URL的代码。标题和内容都很好。什么好主意吗?

<?php
    $mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'desc' ) );
    foreach( $mypages as $page ) {      
        $content = $page->post_content;
        if ( ! $content ) // Check for empty page
            continue;
        $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>
    <?php
    }   
?>

只需添加the_post_thumbnail();即可检索特征图像。有关进一步定制,请参阅此特色图像指南

所以修改后的代码是:

<?php
$mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'desc' ) );
foreach( $mypages as $page ) {      
    $content = $page->post_content;
    if ( ! $content ) // Check for empty page
        continue;
    $content = apply_filters( 'the_content', $content );
?>
    <h2><a href="<?php echo get_page_link( $page->ID ); ?>"><?php echo $page->post_title; ?></a></h2>
    <?php the_post_thumbnail(); ?> // Gets the featured image
    <div class="entry"><?php echo $content; ?></div>
<?php
}   
?>