I’m completely new to PHP, so bear with me.
I am trying to set a variable based on an if else statement. It’s breaking my site, when I try it, so I am assuming it’s not possible.
Something like…
<?php
if ( has_post_thumbnail($some_post['ID']) ) {
$featured_img_url = get_the_post_thumbnail_url($some_post->ID, 'full');
}
else {
echo '<img src="' . get_stylesheet_directory_uri() . '/assets/img/hero-thumbnail-default.jpg" />';
}?>
Essentially, I am using get_recent_posts to pull in some posts as $some_post and I need to check if $some_post has a featured image, if not, I need to echo the fallback image.