Title: Get post category image
Last modified: August 30, 2016

---

# Get post category image

 *  Resolved [totalmac](https://wordpress.org/support/users/totalmac/)
 * (@totalmac)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/get-post-category-image/)
 * I’m trying to show the post category image, but it’s not showing. Any idea what
   I did wrong?:
 *     ```
       <?php
       	$args = array('post_type' => 'post','cat' => '','showposts' => 2,); 	
   
       	$categories = get_categories();
       			foreach ($categories as $category)
       			{
           			$term_id = $category->term_id;
           			$image = category_image_src( array('term_id'=>$term_id) , false );
       			}
       	?>
   
       	<?php $recent = new WP_Query($args); while($recent->have_posts()) : $recent->the_post();?>
   
       	<li>
       		<img src="<?php echo $image; ?>" alt="<?php $alt = get_the_category(); echo $alt[0]->cat_name; ?>" class="align-left">
       		<h2 class="entry-title" itemprop="headline"><a class="news-title" rel="bookmark" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
       	</li>
       	<?php endwhile; ?>
       ```
   
 * [https://wordpress.org/plugins/wpcustom-category-image/](https://wordpress.org/plugins/wpcustom-category-image/)

The topic ‘Get post category image’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wpcustom-category-image_e7b785.svg)
 * [WPCustom Category Image](https://wordpress.org/plugins/wpcustom-category-image/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpcustom-category-image/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpcustom-category-image/)
 * [Active Topics](https://wordpress.org/support/plugin/wpcustom-category-image/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpcustom-category-image/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpcustom-category-image/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [totalmac](https://wordpress.org/support/users/totalmac/)
 * Last activity: [10 years, 7 months ago](https://wordpress.org/support/topic/get-post-category-image/)
 * Status: resolved