如何从Wordpress媒体库中检索元数据?

时间:2011-08-11 22:08:41

标签: wordpress wordpress-theming

在Wordpress媒体库中,当您添加媒体时,还会邀请您添加其他“元数据”:标题,标题,备用文本和说明。

使用get_the_title()会返回标题,但尝试get_the_caption()只会破坏页面。

如何在页面上获取此数据或元数据。我也尝试使用wp_get_attachment_metadata(),它返回一个数组。有谁知道这个数组中有什么值?我知道它有高度和宽度。

1 个答案:

答案 0 :(得分:1)

我看到这个元数据存储在wp_posts表中。例如,照片的标题位于post_excerpt列中。由于标题列为post_title,因此您可能需要尝试相同的命名约定并尝试调用get_the_excerpt()。以下是wp_posts

中列的其他名称

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

希望这有帮助