【发布时间】:2011-11-30 06:47:43
【问题描述】:
我正在使用 Wordpress 自定义字段模板插件 - http://wordpress.org/extend/plugins/custom-field-template/
我创建了一些这样的文件
[slideshow]
type = file
relation = true
label = Images For the Slide show?
[slideshow]
type = file
relation = true
hideKey = true
[slideshow]
type = file
relation = true
hideKey = true
[slideshow]
type = file
relation = true
hideKey = true
我想显示来自文件字段的图像列表,例如
<?php $slide_images = get_post_meta($post->ID, 'slideshow', false); ?>
<ul id="slideshow">
<?php foreach($slide_images as $slide_image) {
echo '<li>'.$slide_image.'</li>';
} ?>
<ul>
http://wordpress.org/support/topic/plugin-custom-field-template-file-and-image-display?replies=13
【问题讨论】:
-
卡在哪里了,哪里出错了?
-
没有错误现在它只打印图像 ID 我想获取图像
wp_get_attachment_url("Image ID", 'full'); -
如果是这样,您可以使用 wp_get_attachment_url($slide_image, 'full');而不仅仅是 $slide_image。
-
得到了解决方案,我做了类似的东西
<?php $slide_images = get_post_meta($post->ID, 'slideshow', false); ?> <ul id="slideshow"> <?php foreach($slide_images as $key=>$slide_image) { $slide_url = wp_get_attachment_image($slide_image, 'full'); echo '<li>'.$slide_url.'</li>'; } ?>谢谢你的帮助
标签: php wordpress custom-fields