如何从 Wordpress 媒体库检索元数据?
在 WordPress 媒体库中,当您添加媒体片段时,系统会邀请您添加其他“元数据”:标题、说明文字、替代文本和说明。
使用 get_the_title()
将返回标题,但尝试 get_the_caption()
只会破坏页面。
如何获取页面上的这些数据或元数据。我还尝试使用 wp_get_attachment_metadata()
,它返回一个数组。有谁知道这个数组中有哪些值?我知道它有高度和宽度。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(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
希望这有帮助
I see that this metadata is stored to the
wp_posts
table. For example, the caption for a photo is in columnpost_excerpt
. Since the title column ispost_title
, you might want to try the same naming convention and try a call toget_the_excerpt()
. Here are the other names of the columns in thewp_posts
tablepost_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