我的WordPress附件表格中有一个自定义字段。
我正在此存储值,现在想在公共端显示该值。
遵循此http://codex.wordpress.org/Function_Reference/wp_get_attachment_metadata,这应该有所帮助,但不能:<?php wp_get_attachment_metadata( $attachment_id, $unfiltered ); ?>
有人可以帮忙吗?
谢谢
wp_get_attachment_metadata结果为:
Array
(
[width] =>
[height] =>
[file] =>
[sizes] => Array
(
[thumbnail] => Array
(
[file] =>
[width] =>
[height] =>
[mime-type] =>
)
[medium] => Array
(
[file] =>
[width] =>
[height] =>
[mime-type] =>
)
)
[image_meta] => Array
(
[aperture] =>
[credit] =>
[camera] =>
[caption] =>
[created_timestamp] =>
[copyright] =>
[focal_length] =>
[iso] =>
[shutter_speed] =>
[title] =>
)
)
因此,这是附件数据。但是您想要获得自定义字段。您可以使用与post相同的内容:
get_post_meta($post->ID, 'your_field_name', true);
所有这些都可以在attachment.php中找到。在附件页面中,$ post是附件帖子,而不是父帖子。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句