wordpressでカスタムフィールドから情報を取得する方法。
$custom_fields = get_post_custom($post_id); print_r($custom_fields);
$post_idは指定しない場合は現在の投稿情報が取得できます。
更にカスタムフィールドの画像情報を取得する場合。
$res = wp_get_attachment_image_src($custom_fields['image_1'][0], 'thumnail'); print_r($res);
で取得可能です。
$custom_fields['image_1'][0]には 先ほど
get_post_custom() で取得した、添付ファイルIDが入っています。
セブ島のIT留学では、この様にwordpressのカスタマイズを勉強できます。
TAGS > get_post_custom, IT留学, wordpressカスタマイズ
NO COMMENT