私のウェブサイトのサブフォルダー (html から変換されたもの) にワードプレスのブログ ページがインストールされており、静的な html ホームページがあります。 ホームページに最新の3つの投稿とそのアイキャッチ画像を表示したいと思います。以下のコードを使用すると、最新の投稿テキストを表示できますが、投稿の注目の画像を表示する方法がわかりません。 wordpress カスタム テーマの index.php に、注目の写真を div 内に配置しました。
<div id="blogphoto"><?php the_post_thumbnail(); ?></div>
これは、最新の投稿を引き出している静的な html index.php ページのコードです。これらの投稿の注目の画像も取得するのを手伝ってくれる人はいますか?
<div id="wp-post">
<?php
$args = array('numberposts'=>1);
$recent_posts=wp_get_recent_posts($args);
foreach( $recent_posts as $recent_post ){
echo "<h3>".$recent_post['post_title']."</h3> <br>";
echo "<span>".$recent_post['post_date']."</span> <br>";
echo "<p>".$recent_post['post_content']."</p><br><br>";
}
?>
</div>
<div id="wp-post2">
<?php
$args = array('numberposts'=>1 , 'offset'=>1 );
$recent_posts=wp_get_recent_posts($args);
foreach( $recent_posts as $recent_post ){
echo "<span>".$recent_post['post_title']."</span> <br>";
echo "<p>".$recent_post['post_content']."</p><br><br>";
}
?>
</div>
<div id="wp-post3">
<?php
$args = array('numberposts'=>1 , 'offset'=>2 );
$recent_posts=wp_get_recent_posts($args);
foreach( $recent_posts as $recent_post ){
echo "<span>".$recent_post['post_title']."</span> <br>";
echo "<p>".$recent_post['post_content']."</p><br><br>";
}
?>
</div>