wordpress 画像 meta情報
■カスタムヘッダーでアップロードした画像の情報取得
・get_uploaded_header_images()
[16]=>
array(6) {
["attachment_id"]=>
int(16)
["url"]=>
string(89) "http://localhost/・・・/wp-content/uploads/2016/04/cropped-img_mainvisual_pc_01.jpg"
["thumbnail_url"]=>
string(89) "http://localhost/・・・/wp-content/uploads/2016/04/cropped-img_mainvisual_pc_01.jpg"
["alt_text"]=>
string(42) "http://localhost/・・・/sample-page/"
["width"]=>
int(940)
["height"]=>
int(400)
}
■投稿IDで指定した投稿のレコードを取得
・get_post(‘ID’)
$img_meta = get_post('ID'); //データを全て取得
$img_title = $img_meta->post_title; //タイトルを取得
$img_caption = $img_meta->post_excerpt; //キャプションを取得
$img_content = $img_meta->post_content; //説明を取得