【发布时间】:2014-03-17 17:06:49
【问题描述】:
我正在使用 wordpress 的“简单字段”插件,并设置了一个字段来上传文件(在本例中为图像)。我使用以下代码可以在前端显示特定的图像/字段:
<?php
$selected_value = simple_fields_get_post_value(get_the_id(), array(1, 1), true);
$theImageURL = wp_get_attachment_url($selected_value);
echo '<img src="'.$theImageURL.'">';
?>
显然在这种情况下,它使用该字段的特定键:_simple_fields_fieldGroupID_1_fieldID_1_numInSet_0
我将如何从帖子连接器中显示多张图片,而无需具体标识每个字段。
就目前而言,如果我要在帖子中包含说 3 张图片,所有将使用数组(1,1)猜测 id 只需要创建所有相关图像的数组
【问题讨论】:
标签: php wordpress custom-fields