从WordPress高级自定义字段数组获取正确的图像url?
Wordpress新手从WordPress高级自定义字段数组获取正确的图像url?,wordpress,wordpress-theming,advanced-custom-fields,Wordpress,Wordpress Theming,Advanced Custom Fields,Wordpress新手 $article_data = get_field('article_item'); foreach ($article_data as $key => $item) { $footerImg = (!empty($item['bottom_image'])) ? $item['bottom_image'] : NULL; $url = implode( ', ', $footerImg ); echo $url; } 其结果如下
$article_data = get_field('article_item');
foreach ($article_data as $key => $item) {
$footerImg = (!empty($item['bottom_image'])) ? $item['bottom_image'] : NULL;
$url = implode( ', ', $footerImg );
echo $url;
}
其结果如下:
2345,
67899,
boston_skyline,
boston_skyline.jpg,
http://localhost:8000/bostontheme/images/2018/08/boston_skyline.jpg,
2018-08-07 01:24:21
如何抓取其中的图像字符串,以便执行以下操作:
<img src="<?php echo $url ?>" />
我得到这个输出:
Array (
[bottom_image] => Array (
[ID] => 67899
[id] => 67899
[title] => boston_skyline
[filename] => boston_skyline.jpg
[url] => http://localhost:8000/bostontheme/images/2018/08/boston_skyline.jpg
您只需要
$item[“底部图像”][“url”]
添加打印($item)改为编码>并用输出更新您的问题。顺便说一句,这不是一个“WordPress自定义字段数组”,它是一个高级自定义字段数组。嗨@PeterHvD我更新了这篇文章以反映你的建议。对印刷品的输出有什么想法吗?
Array (
[bottom_image] => Array (
[ID] => 67899
[id] => 67899
[title] => boston_skyline
[filename] => boston_skyline.jpg
[url] => http://localhost:8000/bostontheme/images/2018/08/boston_skyline.jpg