【发布时间】:2014-07-03 03:11:18
【问题描述】:
我有一个包含多个帖子的 WordPress 网站。在主页上,我设置了一个插件 (https://wordpress.org/plugins/column-posts/),以便显示三列最新帖子。这很好用,我可以在 CSS 中设置列的样式。但是,我希望每个帖子的特色图片成为该帖子专栏的背景?知道我会如何做到这一点吗?
<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>
我想我可以像这样将变量插入 li 样式:
<li style="background:url(<?php'.$thumb.'?>);">
但是,它根本没有回显任何内容,并且肯定没有图像 src。任何让它回显 $thumb 作为背景图像或在该代码中的某处插入背景图像的方法。谢谢!!
谢谢!
【问题讨论】: