The past couple of hours I am trying to find out what is the problem with this...
<?php $related_posts = get_field('related_posts'); ?>
<?php if ($related_posts) : ?>
<div class="related-projects_items-list-container">
<div class="comments-area-title">
<h4 class="hN"><?php _e('<em>Related</em> Articles', wpgrade::textdomain()); ?></h4>
</div>
<ul class="related-projects_items-list grid">
<?php
foreach ($related_posts as $post_object) {
$the_post_ID = $post_object->ID;
$the_permalink = get_permalink( $post_object->ID );
$the_title = get_the_title( $post_object->ID );
$the_thumbnail = get_the_post_thumbnail( $post_object->ID, array(200,150) );
$the_post_author = $post_object->post_author;
?>
<li class="related-projects_item grid__item one-half lap-and-up-one-quarter" style="margin-bottom: 20px;">
<article class="article article--billboard-small">
<a href="<?php echo $the_permalink; ?>">
<div class="article__thumb">
<?php if (has_post_thumbnail( $the_post_ID )) echo $the_thumbnail; ?>
</div>
<div class="article__content">
<h2 class="article__title article--billboard-small__title">
<span class="hN"><?php echo $the_title; ?></span>
</h2>
<span class="article__description">
<?php $author_url = get_author_posts_url( $the_post_author ); ?>
<?php $author_name = get_the_author_meta( 'display_name', $the_post_author ); ?>
<?php echo $author_name; ?> - <?php echo get_post_time('d.m.Y', false, $the_post_ID, false); ?>
</span>
<span class="small-link"><?php _e('Read More', wpgrade::textdomain()); ?><em>+</em></span>
</div>
</a>
</article>
</li>
<?php } ?>
</ul>
</div>
<?php endif; ?>
I get this...
Warning: Invalid argument supplied for foreach() in /wp-includes/post-thumbnail-template.php on line 64
The problem is this line...
$the_thumbnail = get_the_post_thumbnail( $post_object->ID, array(200,150) );
I can't understand why! Can someone please help?
I am using WordPress v.3.9.1