Search code examples
wordpressaction-filter

Trying to insert a linked featured image into the content


I am using filter hook to insert a featured image into the_content, that works, but when I try to wrap the featured image in an anchor tag, the link tag ends up directly after the content(not wrapping the image at all)

Is there something I am missing as far as understanding how to filter the_content()? Here's my code:

add_filter('the_content', 'add_img_to_ps_archive');

function add_img_to_ps_archive($content) {
if (is_post_type_archive('past_symposia') ) {
echo $content . '<a href ="#" "alignleft">' . the_post_thumbnail('symposia-thumb') .   
'</a>'; 
} elseif( is_singular('past_symposia') ) {
echo $content . '<br />';
} else {
return $content; 
}
}

Solution

  • Try to use commas ',' and not dots '.' for concatenating - don´t ask me why, but wordpress does that sometimes...