希望有人可以幫助。我已經把這段代碼放到了一個標準模板中,但是沒有顯示圖片,儘管事實上我已經有了一堆帶有圖片的帖子。WordPress的:顯示張貼在首頁的圖像
<?php if (have_posts()) : while (have_posts()) : the_post();
$images =& get_children(array (
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image'
));
if (empty($images)) {
// no attachments here
} else {
foreach ($images as $attachment_id => $attachment) {
echo wp_get_attachment_image($attachment_id, 'thumbnail');
}
}
endwhile; endif; ?>
感謝您的幫助!
你只需要顯示的圖像,沒有別的。並且圖片是否設置爲特色圖片 –
不可以,它們不會被設置爲特色圖片。我只需要顯示圖像;我將使用砌體和CSS來定位它們。 – natnai