wordpressで記事IDに紐づいた情報が欲しい
wordpressで関連記事の機能を実装しているときに使った
タイトル
echo get_the_title($postID);
関数リファレンス/get the title - WordPress Codex 日本語版
投稿日時
echo get_the_time("Y.n.j", $postID);
テンプレートタグ/get the time - WordPress Codex 日本語版
カテゴリ
$cat = get_the_category($postID);
echo $cat[0]->cat_name;
テンプレートタグ/get the category - WordPress Codex 日本語版
サムネイル画像
$thumb_id = get_post_thumbnail_id($postID); $thumb_url = wp_get_attachment_image_src( $thumb_id , 'medium' ); // 以下は表示したい箇所で <img src="<?php echo $thumb_url[0]; ?>">
テンプレートタグ/get post thumbnail id - WordPress Codex 日本語版
関数リファレンス/wp get attachment image src - WordPress Codex 日本語版
リンク
<a href="<?php the_permalink($postID); ?>" class="clr">