When I was working on a quick Schema.org Microdata project, I wanted to get Genesis Featured Image for each post as well as all other images attached in the post body.
This code snippet will get just the Featured Image URL without any HTML tags in Genesis sites,
$featuredimage = genesis_get_image( array(
'format' => 'url',
'size' => 'full',
) );
echo $featuredimage;
Then following code will get all other images attached in the post to an Array. Then I got 2 Array Keys to output just the Image URL again,
$images = get_children( array (
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'exclude' => get_post_thumbnail_id()
));
if (current($images)) {
$key1 = key($images);
}
if (next($images)) {
$key2 = key($images);
}
echo $images[$key1]->guid;
echo $images[$key2]->guid;
Leave a Reply