【发布时间】:2013-04-21 21:48:08
【问题描述】:
我正在使用 WordPress 和高级自定义字段,并且我想显示 3-6 张图像,具体取决于在选择字段帖子类型上选择了哪些字段。
我有它,因此值/变量与图像名称相关联,因此它会显示根据您的选择选择的图像。
例如“红色:红色”
<img src="example.com/images/image-<?php the_field(color) ?>.jpg" alt="<?php the_field(color) ?>">
Now the noob question is, when more than one field is selected, it returns an array (i.e. red, green, black.) and I can't really have the function output as an array since it won't match the图像名称。
有人知道如何为多个图像输出分离一个数组吗?
【问题讨论】:
-
您是在问如何从数组中检索项目?
-
是的,但我希望数组中的所有项目根据值名称分别显示为图像。到目前为止,我正在使用 foreach ($image_list as $image) { printf('', $image['gem_selection_3' ], $image['gem_selection_3']); }
标签: php