I need to show the thumbnail size images (not featured thumbnail) from the posts on the "related posts", code below:
Thumbnail size (the images you insert into the posts from Media library) -vs- Featured thumbnail (is the new function "post-thumbnails" that you can attach an only image as featured image)
What I need:
[1] if the post has an only image, show it.
[2] if it has multi images, show the first.
[3] if non-images, show a static alternative.
Can anyone modify the code below, or have other good snippets to make that happen please? Many thanks!
<?php
$categories = get_the_category($post->ID);
if ($categories) {
$category_ids = array();
foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
$args=array(
'category__in' => $category_ids,
'post__not_in' => array($post->ID),
'showposts'=> 5, // Number of related posts that will be shown.
'caller_get_posts'=> 1
);
$my_query = new wp_query($args);
if( $my_query->have_posts() ) {
echo '<h3>Related Posts</h3>';
echo '<ul>';
while ($my_query->have_posts()) {
$my_query->the_post();
?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php
}
echo '</ul>';
}
}
wp_reset_query(); ?>