Php ACF pro中继器字段随机行输出
我有这个密码Php ACF pro中继器字段随机行输出,php,wordpress,plugins,advanced-custom-fields,Php,Wordpress,Plugins,Advanced Custom Fields,我有这个密码 <?php $rows = get_field('brand_section', 56 ); // get all the rows $rand_row = $rows[ array_rand( $rows ) ]; // get a random row $rand_row_image = $rand_row['brand_specific' ]; // get the sub field value // Note // $first_row_
<?php
$rows = get_field('brand_section', 56 ); // get all the rows
$rand_row = $rows[ array_rand( $rows ) ]; // get a random row
$rand_row_image = $rand_row['brand_specific' ]; // get the sub field value
// Note
// $first_row_image = 123 (image ID)
$image = wp_get_attachment_image_src( $rand_row_image, 'full' );
// url = $image[0];
// width = $image[1];
// height = $image[2];
?>
<img src="<?php echo $image[0]; ?>" />
错误是它没有输出任何类似img src的内容是未知的我不太理解这个问题,但我知道需要是
get_sub_字段()
或the_sub_字段
(取决于您的模板用法),而不是get_字段()
也许这就是你问题的根源
-reapeater field
--group(that can be reapeted)
---img
---link
---link2