Right next to my post I would like to have a "About this featured image section" which in short pulls in the data using
wp_get_attachment_metadata its cake on a page like
image.php where the attachment_id is in
$_GET, But i'm trying to do this on my single-post.php page. Below is my working code:
global $post; global $wpdb; $query = " SELECT ID FROM $wpdb->posts WHERE post_parent = '$post->ID' AND post_status = 'inherit' AND post_type='attachment' ORDER BY post_date DESC LIMIT 1"; $attachment_id = $wpdb->get_var($query); $url = get_attachment_link($attachment_id); $urlArray = parse_url($url); $queryStringArray = explode('=', $urlArray['query']); $attachment_id = $queryStringArray; // assign some info $meta_array = wp_get_attachment_metadata($attachment_id);
It works it gives me an array of attachment metadata, but I feel like i went the long way around the bush with this one. Any help on using some of the built in functions in wordpress to clean this up?