如何在古腾堡编辑器中按帖子id显示帖子特色图像?我有一个滑块,上面有最新的帖子,当我反复浏览这些帖子时,我也想显示帖子的特色图片。下面是我的示例片段
const cards = displayPosts.map( ( post, i ) => {
console.log(post.featured_media)
return(<div className="card" key={i}>
<div className="card-image">
<div className="image is-4by3">
<PostFeaturedImage
currentPostId = {post.id}
featuredImageId = {post.featured_media}
/>
<div className="news__post-title">
<div className="title is-5">
<a href={ post.link } target="_blank">{ decodeEntities( post.title.rendered.trim() ) || __( \'(Untitled)\' ) }</a>
{ displayPostDate && post.date_gmt &&
<time dateTime={ format( \'c\', post.date_gmt ) } className="wp-block-latest-posts__post-date">
{ dateI18n( dateFormat, post.date_gmt ) }
</time>
}
</div>
</div>
<div className="card-content">
<div className="content">
<p dangerouslySetInnerHTML={ { __html: post.excerpt.rendered } }></p>
</div>
</div>
</div>
</div>
</div>)
})