Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 67836

Grabbing post thumbnails

$
0
0

Replies: 0

Hi everyone,

Love the Customizr theme. Thanks for all your help.

I am grabbing the 3 most recent posts and displaying them in the sidebar like this:


<div class='text-widget'>
   <ul>
	<?php echo get_the_post_thumbnail($post['ID'], 'thumbnail'); ?>
	<?php
	$args = array( 'numberposts' => '3' );
	$recent_posts = wp_get_recent_posts( $args );
	foreach( $recent_posts as $recent ){
		echo '<a href="' . get_permalink($recent["ID"]) . '"><li>' .   $recent["post_title"].'</li></a>';
	}
	?>
</ul>
</div>

I’d like to add a thumbnail image for each post. Possibly using get_the_post_thumbnail? Like this?


<div class='text-widget'>
   <ul>
	<?php echo get_the_post_thumbnail($post['ID'], 'thumbnail'); ?>
	<?php
	$args = array( 'numberposts' => '3' );
	$recent_posts = wp_get_recent_posts( $args );
	foreach( $recent_posts as $recent ){
		echo '<a href="' . get_permalink($recent["ID"]) . '"><li>' .   $recent["post_title"].'</li>' . get_the_post_thumbnail($post['ID'],'thumbnail');'</a>';
	}
	?>
</ul>
</div>

Any help is much appreciated. Here’s the site


Viewing all articles
Browse latest Browse all 67836

Trending Articles