将页面特色图像添加到foreach循环中

时间:2013-08-08 13:27:12

标签: wordpress loops

我有一个foreach循环,显示子页面标题,内容和URL的列表。我似乎无法显示特色图像!这就是我所拥有的:

<?php
$pageChildren = get_pages('sort_column=menu_order&hierarchical=0&child_of='.$post->ID);
if ( $pageChildren ) {
foreach ( $pageChildren as $pageChild ) {
echo '<div style="position:relative;float:left;width:100%;margin:0 0 20px 0;border-bottom:1px dashed #cdcdcd;padding:0 0 20px 0">';
//FEATURED IMAGE HERE
echo '<a class="newstitle" href="' . get_permalink($pageChild->ID) . '">' . $pageChild->post_title.'</a><br /><br />';
if (!empty($pageChild->post_content)){
        echo '<p>'.$pageChild->post_content.'</p> ';
        echo '<a class="readmore" href="' . get_permalink($pageChild->ID) . '" style="float:left">Read More &raquo;</a>';
    }
    echo '</div>';
}
}
?>

1 个答案:

答案 0 :(得分:1)

你必须使用

<?php echo get_the_post_thumbnail($pageChild->ID ); ?> 

获取帖子缩略图以及页面