我有一个自定义的帖子类型“Artworks”,带有自定义的分类“Artists”。我有一个页面,其中列出了“艺术家”分类法中的所有条目(艺术家1、艺术家2、艺术家3等)。
如何从每个类别(艺术家1、艺术家2等)的最新帖子中获取图片?
我就是这样列出“艺术家”分类法中的条目的:
<style>
.artistbox {
width:100%;
height:150px;
}
</style>
<?php
$tax_terms = get_terms(\'artists\', array(\'hide_empty\' => \'1\'));
foreach ( $tax_terms as $tax_term ):
echo \'<div class="artistbox" style="background-image: url(\'?????????\');"><a href="/artists/\'.$tax_term->slug.\'">\'.$tax_term->name.\'</a></div>\';
endforeach;
?>
我想要?????????成为每个类别中最新帖子的特色图片的URL。我该怎么做?Like this:
<div style="background-image:URL(\'featured-image-of-latest-post-assigned-to-artist-1;">
Artist 1
</div>
<div style="background-image:URL(\'featured-image-of-latest-post-assigned-to-artist-2;">
Artist 2
</div>
<div style="background-image:URL(\'featured-image-of-latest-post-assigned-to-artist-3;">
Artist 3
</div>
... and so on.