I have a WordPress site with multiple posts. On the homepage I have setup a plugin (https://wordpress.org/plugins/column-posts/) so that three columns of the most recent posts are displayed. That works well and I'm able to style the columns in CSS. However, I want each post's featured image to be the background of that post's column? Any idea how I'd make this happen?
<ul>
';
}
// thumbnail
$thclear = '';
$bullet = '<li style="background:url(<?php'.$thumb.'?>);">';
$thumb = '';
if ( $args['thumb'] ) {
if ( has_post_thumbnail($post->ID) ) {
//$bullet = '';
$thclear = '<div style="clear:both;"></div>';
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), $args['tsize'], false, array('class'=>"alignthumb"));
}
}
$ppost .= $bullet .'<a href="'.get_permalink($post->ID).'" title="'.sprintf(__('Article %s published at %s', 'cp'), $title_full, date_i18n(__('F j, Y g:i a'), strtotime($post->post_date)) ).'">'.$title.'</a>';
// excerpt
if ( $args['excerpt'] ) {
$ppost .= '<p>' .get_the_excerpt() .'</p>' .$thclear .'</li>';
}
else{
$ppost .= $thclear .'</li>';
}
if ($args['class'] == 'P' && $args['col_cnt'] == $args['col_post'])
$ppost .= '
</ul>
I figured I could plug a variable into li style like this:
<li style="background:url(<?php'.$thumb.'?>);">
However it's not echoing anything at all and no image src for sure. Any way to get it to echo $thumb as the background image or plug a background image somewhere in that code. Thanks!!
Thanks!