开发者

How do I retrieve metadata from the Wordpress Media Gallery?

In the Wordpress Media Library, when you add a piece of media, you're invited to also add other 'metadata': Title, Caption, Alternate Text, and Description.

Using get_the_title() will return the title, but trying get_the_caption() simply breaks the page.

How do I get this data, or metadata on the page开发者_开发技巧. I've also tried using wp_get_attachment_metadata(), which returns an array. Does anyone know what values are in this array? I know it has height and width.


I see that this metadata is stored to the wp_posts table. For example, the caption for a photo is in column post_excerpt. Since the title column is post_title, you might want to try the same naming convention and try a call to get_the_excerpt(). Here are the other names of the columns in the wp_posts table

post_author post_date post_date_gmt post_content post_title post_excerpt post_status comment_status ping_status post_password post_name to_ping pinged post_modified post_modified_gmt post_content_filtered post_parent guid menu_order post_type post_mime_type comment_count

Hope this helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜