I have a strange problem which I'm hoping is just due to me missing something obvious...
Our Wordpress installation has upgraded to 3.8.1 recently. We use WordPress within a directory on the site as part of our news items. We loop through posts in other sections of our site to show latest news etc
We have featured image enabled, and have the featured images showing on the wordpress/news home page by using the following code:
<a href="<?php the_permalink() ?>"><div class="snippet-featured-img"><?php the_post_thumbnail('thumbnail'); ?></div></a>
This works fine, and outputs the 150px by 150px featured image.
We also wish to show the featured image next to the posts we loop through on the other pages of the site, but we can't seem to get it working.
This is the code:
foreach($posts as $post) {
setup_postdata($post);
if ( has_post_thumbnail() ) {
echo "<a href='";
echo the_permalink();
echo "'>";
the_post_thumbnail(array('50','50'));
echo "</a>";
}
echo "<h2><a href=\"";
echo the_permalink();
echo "\" rel=\"bookmark\" title=\"Permanent Link to ";
echo the_title();
echo "\">";
echo the_title();
echo "</a></h2>\n<p>";
$string = strip_tags(strip_shortcodes($post->post_content));
echo chop_string($string,190,'...');
echo " <a href=\"";
echo the_permalink();
echo "\" rel=\"bookmark\" title=\"Permanent Link to ";
echo the_title();
echo "\">";
echo "Read More</a></p>\n";
echo "<div class='clear'></div>\n";
}
The post var is declared a bit higher up the script:
$posts = get_posts('numberposts=8&orderby=date');
Everything except the image is outputted, even the link around where the image should be is outputted, indicating that the has_post_thumbnail() func has returned true. As I said, it's also working on the wordpress page itself.
I have tried with 'thumbnail' passed instead of the size array, and also get_the_post_thumbnail(), and I'm at a loss as to why it's not working!
Any help would be great
Thanks