Use an is_single()
condition to ensure the thumbnail isn’t added on archive pages. You should also be using get_the_post_thumbnail
and prepending it to $content
, rather than just echo’ing it out:
function put_thumbnail_in_posting( $content ) {
if ( is_single() && has_post_thumbnail() && get_post_type() == 'post' ) {
$thumbnail = get_the_post_thumbnail( null, '',
array(
'style' => implode( ' ',
array(
'padding: 6px;',
'margin-bottom: 8px;',
'margin-right: 8px;',
'max-width: 100%;',
'border: 1px solid rgb(204, 204, 204);',
'background: none repeat scroll 0% 0% rgb(238, 238, 238);',
)
)
)
);
$content = $thumbnail . $content;
}
return $content;
}