我所有的發佈縮略圖,我目前正在使用一個佔位符圖像工作正常,但希望使用特色圖像形式的帖子作爲背景,這裏是我的代碼...WordPress的發佈縮略圖問題
<?php
$args = array('posts_per_page' => 10, 'category' => 3);
$myposts = get_posts($args);
foreach ($myposts as $post) : setup_postdata($post); ?>
<div class="box" style="background-image:url('<?php the_post_thumbnail(); ?>');">
<div class="overlay">
<div class="buttonContainer">
<a href="<?php the_permalink(); ?>">
<button>preview</button>
</a>
</div>
</div>
</div>
<?php endforeach;
wp_reset_postdata();?>
當我在瀏覽器中查看它時,它會打印出此... ');">
而且沒有圖像...我在哪裏出錯了?
你試過'echo the_post_thumbnail()'嗎? – pbaldauf 2015-02-07 20:09:42
我做了,沒有出現... – coder123 2015-02-07 20:09:57
嘗試移出它'<?php the_post_thumbnail(); ?'''''style'標籤,並將其與''標籤一起放置,以便您可以直接看到它的內容。 – Stickers 2015-02-07 20:33:06