Blog (Post Summary) Page Display Featured Image from Post
-
Is it possible to have the Featured Image for each separate post displayed on the Blog (Post Summary) Page be the same as the image/photo used in the actual post which is from an external (URL) source?
I’m using a content curation plugin that automatically populates new posts with the text and photo (where applicable) from the original online source and would like the same image displayed as the featured image next to the post summary as well as on the Recent Posts carousel.
The plugin developer support team provided me with a php code to use but I have no idea how (where or if) the virtue theme calls images for the Blog/Post Summary Page (i.e. index.php, single.php, archive.php etc.).
That stated, even if I were to identify where to apply the supplied code, as a novice ‘coder’, I would be unsure specifically where the code should be inserted (i.e. above or below existing, between specific tags etc.).
The supplied code is as follows (*note – I have created a child theme as a backup):function UNIQUE_NAME_theme_thumbnail($pID,$thumb=’medium’) {
$imgsrc = FALSE;
if (has_post_thumbnail()) {
$imgsrc = wp_get_attachment_image_src(get_post_thumbnail_id($pID),$thumb);
$imgsrc = $imgsrc[0];
} elseif ($postimages = get_children(“post_parent=$pID&post_type=attachment&post_mime_type=image&numberposts=0”)) {
foreach($postimages as $postimage) {
$imgsrc = wp_get_attachment_image_src($postimage->ID, $thumb);
$imgsrc = $imgsrc[0];
}
} elseif (preg_match(‘/<img [^>]*src=[“|\’]([^”|\’]+)/i’, get_the_content(), $match) != FALSE) {
$imgsrc = $match[1];
}
if($imgsrc) {
$imgsrc = ‘<img src=”‘.$imgsrc.'” alt=”‘.get_the_title().'” class=”summary-image” />‘;
return $imgsrc;
}
}
- The topic ‘Blog (Post Summary) Page Display Featured Image from Post’ is closed to new replies.