I am trying to list the url to the first image attached to each post. The code im using outputs the images with <img> tags... Even with 'return_html' => 'false'
Here is what I have so far:
<?php
function postimage($size=thumbnail) {
if ( $images = get_children(array(
'post_parent' => get_the_ID(),
'post_type' => 'attachment',
'numberposts' => 1,
'order' => 'ASC',
'orderby' => 'ID',
'post_mime_type' => 'image',
'return_html' => 'false',)))
{
foreach( $images as $image ) {
$attachmenturl=wp_get_attachment_url($image->ID);
$attachmentimage=wp_get_attachment_image( $image->ID);
echo $attachmentimage;
}
} else {
echo "No Image";
}
}
if (have_posts()) :
while (have_posts()) : the_post();
// List the images
echo postimage('thumbnail');
endwhile;
else : ?>
<div class="entry">
<h2>Not Found</h2>
Sorry, but you are looking for something that isn't here.
</div>
<?php endif; ?>
Please help.