• Resolved totalmac

    (@totalmac)


    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://www.ads-software.com/plugins/wpcustom-category-image/

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