0
我無法顯示我的背景圖像。在循環內顯示背景圖像和if語句wordpress
我創建了一個循環來顯示我的帖子,然後試圖設置背景圖像,但是它打破了某個地方?以下是我在循環中的代碼。
<div class="artist-feed">
<?php
$artistloop = new WP_Query(array('post_type' => 'artist'));
if ($artistloop->have_posts()) :
while ($artistloop->have_posts()) : $artistloop->the_post(); ?>
<a href="<?php the_permalink(); ?>">
<div class="single-artist" style="background-image: url(<?php echo the_post_thumbnail(); ?>);">
<div class="artist-info">
<h2><?php echo get_the_title(); ?></h2>
</div>
</div>
</a>
<?php endwhile;
endif;
wp_reset_postdata();
?>
</div>
謝謝克里斯!這麼簡單......我不敢相信我忽略了它。 –
沒問題:)它花了我永遠也弄清楚了這一點..我只是很高興WordPress的最後添加了一個方法'get_the_post_thumbnail_url()' – Chris