Skip to content

Instantly share code, notes, and snippets.

@smartdeal
Created December 26, 2016 18:20
Show Gist options
  • Save smartdeal/498aa2e27a9a176289a27cd3e92653f4 to your computer and use it in GitHub Desktop.
Save smartdeal/498aa2e27a9a176289a27cd3e92653f4 to your computer and use it in GitHub Desktop.
wordpress get meta attachments
function wp_get_attachment( $attachment_id ) {
$attachment = get_post( $attachment_id );
return array(
'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
'caption' => $attachment->post_excerpt,
'description' => $attachment->post_content,
'href' => get_permalink( $attachment->ID ),
'src' => $attachment->guid,
'title' => $attachment->post_title
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment