Displaying a featured image (only img url) as the img src?

Here are the functions you need to be aware of:

Example sans size:

echo wp_get_attachment_url(get_post_thumbnail_id());

Example with size:

$image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');
echo $image[0]; //as HREF in your A tag

You can grab all of the gallery images as follows:

$args = array(
    'order'=> 'ASC',
    'post_mime_type' => 'image',
    'post_parent' => $post->ID,
    'post_type' => 'attachment'
);

$attachments = get_children( $args );

foreach($attachments as $attachment){
    //use $attachment->ID to retrieve attachment information
    $image = wp_get_attachment_image_src($attachment->ID, 'large');
}

Leave a Comment