Hi @sarahsas,
Thanks for using our plugins.
Unfortunately, this feature isn’t available in our Related Post plugin. But you can achieve this functionality with a little bit of custom coding.
Just copy all the code from below, and from your WordPress dashboard, go to Appearance => Theme File Editor, and from the right-hand sidebar, select Theme Functions file. Now scroll down at the bottom of the file, paste the code, and update. Now the related post will pull up an image from your post content, not from the thumbnail. You can follow the screenshot: https://i.imgur.com/b7oBSkY.png
Code:
add_action( 'related_post_loop_item_element_post_thumb', 'remove_related_post_thumbb' );
function remove_related_post_thumbb() {
remove_action( 'related_post_loop_item_element_post_thumb', 'related_post_loop_item_element_post_thumb' );
}
add_action('related_post_loop_item_element_post_thumb', 'related_post_loop_item_element_post_thumb_20200126', 10, 2);
function related_post_loop_item_element_post_thumb_20200126($loop_post_id, $elementData)
{
$html_thumb = '';
$thumb_linked = 'yes';
$item_post_permalink = get_permalink($loop_post_id);
$post = get_post($loop_post_id);
$post_content = $post->post_content;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post_content, $matches);
if (!empty($matches[1][0]))
$first_img = isset($matches[1][0]) ? $matches[1][0] : '';
if (empty($first_img)) {
$html_thumb .= '';
} else {
if ($thumb_linked == 'yes') {
$html_thumb .= '<a href="' . $item_post_permalink . '"><img src="' . $first_img . '" /></a>';
} else {
$html_thumb .= '<img src="' . $first_img . '" />';
}
}
echo $html_thumb;
}
Let us know if it helps.
Regards.