我有一个网页,使用ACF中继器字段调用来自wordpress的7个图像。如何使用ACF在PHP中随机化URL列表?
我想要做的是获取图像的URL列表,然后将它们洗牌,以使它们的图像随机出现在网页上。当我使用($image['url'])
调用图像时,显示的唯一图像是上传到WordPress网站的最后一幅图像。
<?php
// Call the ACF Gallery images
$imageArray = get_field('company_logos', 13);
$size = 'full'; // (thumbnail, medium, large, full or custom size)
if($imageArray):
while(have_rows('company_logos', 13)) : the_row();
$image = get_sub_field('image');
// $content = get_sub_field('content');
//shuffle ($image['url']);
$arr = $image['url'];
shuffle($arr);
print_r($arr);
endwhile;
endif; ?>
当我回声出图像的URL,以他们的格式出来的画面:
http://localhost/wordpress/wp-content/uploads/2016/07/a.jpg
http://localhost/wordpress/wp-content/uploads/2016/07/b.png
http://localhost/wordpress/wp-content/uploads/2016/07/c.jpg
http://localhost/wordpress/wp-content/uploads/2016/07/d.jpg
http://localhost/wordpress/wp-content/uploads/2016/07/e.jpg
http://localhost/wordpress/wp-content/uploads/2016/07/f.jpg
http://localhost/wordpress/wp-content/uploads/2016/07/g.jpg
任何人都知道如何做到这一点? 谢谢!
请澄清您的具体问题或添加其他详细信息以突出显示您需要的内容。正如目前所写,很难确切地说出你在问什么。请参阅[如何提问](http://stackoverflow.com/help/how-to-ask)页面以获得澄清此问题的帮助。 –
第一篇文章的道歉,这是否更有意义? – HowsThatMonkey