douba05167 2015-05-28 13:41
浏览 42

我正在尝试使用ACF中继器在wordpress网站上调用随机图像

This is my code, as aforesaid - i'm trying to get a single picture to echo inside a premade div out of repeater element. Despite working directly with the example on the website - I would love some help.

<?php 

$repeater = get_field('left_column_repeater' ); // get all the rows
$rand_row = $repeater[ array_rand( $repeater ) ]; // get a random row
$rand_row_image = $rand_row['left_column_image' ]; // get the sub field value 

// Note
// $first_row_image = 123 (image ID)

$image = wp_get_attachment_image_src( $first_row_image, 'full' );

// url = $image[0];
// width = $image[1];
// height = $image[2]; ?>

<div class="circular" style="background-image: url('<?php echo $image[0]; ?>');"> </div>

Where did I go wrong?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计