Retrieve caption of image correct format is
<?php $post_thumbnail_id = get_post_thumbnail_id( $post_id ); ?>
<?php
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
);
}
$at= wp_get_attachment($post_thumbnail_id);
print_r($at);//show array of all image detail like title , caption etc
?>
Related Posts:
- How to get meta value in wp_attachment_metadata
- Removing height and width from images with a caption
- Retrieving post meta array (attachment)
- How to join Caption AND Description Meta Fields as one combined-caption in Image Block
- How to Display Image Caption but Not Alt Text
- How do I retrieve the slug of the current page?
- Most efficient way to get posts with postmeta
- Get posts by meta value
- Explanation of update_post_(meta/term)_cache
- How to extract data from a post meta serialized array?
- How to save an array with one metakey in postmeta?
- WordPress is stripping escape backslashes from JSON strings in post_meta
- Get Image Description
- How can I get the post ID from a WP_Query loop?
- Check if Post Title exists, Insert post if doesn’t, Add Incremental # to Meta if does
- How to update_post_meta value as array
- Adding meta tag without plugin
- What’s the point of get_post_meta’s $single param?
- What is the different between an attachment in wp_posts and an attachment in wp_postmeta?
- How to edit a post meta data in a Gutenberg Block?
- Sanitizing integer input for update_post_meta
- post formats – how to switch meta boxes when changing format?
- How to have different captions for same image, for galleries?
- Execute action after post is saved with all related post_meta records (data)
- How to modify an image block in Gutenberg WordPress 5?
- Lack of composite indexes for meta tables
- Featured image shortcode
- Get a single post by a unique meta value
- if get_post_meta is empty do something
- How we get_post_meta without post id
- How get post id from meta value
- What is the code to get the download link for a product in WooCommerce?
- Safe to delete blank postmeta?
- advanced custom fields update_field for field type: Taxonomy
- update_post_meta not saving when value is zero
- Content hooks vs User hooks
- Meta compare with date (stored as string) not working
- Trying to get custom post meta through Jetpack JSON API [closed]
- How to wrap WordPress image captions inside H2, H3 tags?
- How to update/insert custom field(post meta) data with wordpress REST API?
- Restrict post edit/delete based on user ID and custom field
- get_post_meta returning empty string when data shows in the database
- publish_post action hook doesn’t give post_meta_data
- Remove WordPress.org Meta link
- Remove post meta keys
- How to access the post meta of a post that has just been published?
- Why time functions show invalid time zone when using ‘c’ time format?
- Why is get_post_meta returning an array when I specify it as single?
- How to delete outdated, wrongly sized images in _wp_attachment_metadata?
- How to update/delete array in post meta value?
- How to get all term meta for a taxonomy – getting term_meta for taxonomy
- Adding an assisting editor box to Post page
- Is there a way to define a default caption to all uploaded images
- delete unused postmeta
- How to add a link in a image’s caption?
- Should I sanitize custom post meta if it is going to be escaped later?
- Add post meta based on another post meta value before publish post
- Alter media caption/description conflict in WordPress?
- Multi-line captions on attachments
- How do I retrieve multi-dimensional arrays from the wp_postmeta table, & display on a website?
- Front-end update_post_meta snippet displays white screen?
- Query between two meta values?
- Save both current and new version of post meta
- How to display a shortcode caption somewhere other than the_content
- Caption in Page adding unwanted 10px to width
- Get Advanced Custom Fields values before saving [closed]
- Give extra post-meta to RSS feeds
- WP REST API “rest_no_route” when trying to update meta
- Clean up output added via wp_head()
- List posts under meta_value heading
- Why am I getting an infinite loop with have_posts?
- get_post_meta – get a single value
- delete value 0 in post meta [closed]
- Display info from custom fields in all images’ HTML
- Can I safely delete a record, manually, in the wp postmeta table?
- How to store post meta in an array?
- What action hook updates post meta?
- Can’t translate the post meta data (Date) in another language
- get_post_meta / update_post_meta array
- How to get source of custom meta image?
- adding a URL to a post meta
- Get post embedded image caption
- Exclude a category from the filed under list
- copy attachments to another post type and change attachment url
- Short of raw SQL, can I query for multiple attachment metadata that have a given array key?
- Adjust image caption within visal editor
- How do I access post meta data when publishing a new post in Gutenberg?
- update_post_meta() not working when used with WordPress action
- Drag images with caption in WP editor
- Using Advanced Custom Field (ACF) to insert meta description on each page
- Triple meta_key on custom SELECT query
- get_post_custom()
- Adding meta data to an attachment post
- update_post_meta not adding anything.(Nor add_post_meta)
- loop through all meta keys with get_post_meta
- Get posts by meta value with date
- How to add meta tag to wordpress posts filter?
- Are multiple values from get_post_meta guaranteed to be ordered?
- Different captions for the same image in multiple galleries. Edit Image in Gallery locally
- Identifying Importer Posts