How to get Title, Image and excerpt of posts of a specific category WordPress

I want to get the Post title, image and excerpt of the specific WordPress category. I am using the below code to get the post titles of the specific category.

global $post;
$myposts = get_posts('numberposts=5&category_name=Cooling Towers');
foreach($myposts as $post) :
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?> 

Any ideas, how do I get post image as well as excerpt for the specific WordPress category?

Related posts

Leave a Reply

1 comment

  1. You can use this

    <?php
        query_posts( array('posts_per_page'=>5, 'category_name'=>'Cooling Towers') );
        while ( have_posts() ) : the_post();
    ?>
        <h2><a href="<?php the_permalink(' ') ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
        <?php if ( has_post_thumbnail() ): // check for the featured image ?>
        <a href="<?php the_permalink(' ') ?>" title="<?php the_title(); ?>" class="opacity"><?php the_post_thumbnail(); ?></a> <!--echo the featured image-->
    <?php
        endif;
        the_excerpt(); // echo the excerpt
        endwhile;
        wp_reset_query(); // resets main query
    ?>