Quantcast
Channel: Tagged with repeater - Plugin Support
Viewing all articles
Browse latest Browse all 160

Problem with retrieving Random Row from within Repeater

$
0
0

I attempted to use this resource as a basis: http://www.advancedcustomfields.com/resources/field-types/repeater/#wpshdo_5 but it doesn't seem to work.

I replaced the placeholder text with my values, as shown in this screenshot: https://www.evernote.com/shard/s97/sh/0f99bb64-b1ea-4fea-812f-ad6322ac3be6/8cfc96c20f229601d719906a50b9c2ed

Like so:

` <?php if ( get_field('text_banner') ) { ?>

<?php
    $rows = get_field('text_banner'); // get all the rows
    $rand_row = array_rand( $rows ); // get a random row        
    $rand_row_image = $rand_row['text_banner_image']; // get the sub field value 

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

    ?>

    <img src="<?php echo $image[0]; ?>" />

</div>

<?php } ?> `


Viewing all articles
Browse latest Browse all 160

Trending Articles