This is the syntax problem:
$content .= '<img src="'.($post->the_post_thumbnail->small).'" />';
The the_post_thumbnail()
function is not part of the $post
object, and would print, rather than return, the post thumbnail, even if that method would work.
Try using get_the_post_thumbnail()
instead:
$thumbnail = get_the_post_thumbnail( $post->ID, 'small' );
Note that this function returns the fully formed <img>
tag markup, so you would need to adapt your code accordingly:
$content .= get_the_post_thumbnail( $post->ID, 'small' );
Edit
Note that 'small'
is an image size already defined by WordPress, so you’ll want to use a different name. I would use something location-descriptive, such as 'post-two-column'
:
add_image_size( 'post-two-column', 120, 120, true );
Then, reference accordingly in your loop:
$content .= get_the_post_thumbnail( $post->ID, 'post-two-column' );