最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

functions - What are the meta fields for an attachment?

programmeradmin4浏览0评论

I'm trying to find all the meta fields that are used for an attachment: like Title, alternative text, description and caption . I've looked all over and the only one I was able to find was for an Alternative text, which is _wp_attachment_image_alt.

I'm trying to find all the meta fields that are used for an attachment: like Title, alternative text, description and caption . I've looked all over and the only one I was able to find was for an Alternative text, which is _wp_attachment_image_alt.

Share Improve this question asked Oct 13, 2020 at 2:27 Gregory SchultzGregory Schultz 6236 silver badges31 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

You can easily inspect all the metadata for any post like so:

// 123 is the (attachment) post ID
var_dump( get_post_meta( 123 ) );

And in a default WordPress setup with no plugins or theme which add custom metadata to the image attachment post, the metadata you'd get are:

  • _wp_attached_file — string, the image file (path and name) for the attachment post

  • _wp_attachment_metadata — array (serialized), the sizes for the image like 'thumbnail' (including original size), and metadata from EXIF/IPTC info.

  • _wp_attachment_image_alt — string, the image's alternative text

As for the other details like the image title, they are in the post data (in the posts database table), so you can for example use wp_update_post() to update these details:

  • post_title — image title

  • post_excerpt — image caption

  • post_content — image description

发布评论

评论列表(0)

  1. 暂无评论