Support

Account

Home Forums Front-end Issues Showing one random post object from a sub_field list Reply To: Showing one random post object from a sub_field list

  • Hi @qhuit

    In this case, I suggest you use the get_field() function and show the random row using the array_rand() function. It should be something like this:

    $repeater = get_field('products');
    $post_object = $repeater[array_rand($repeater)]['product_image'];
    
    if( $post_object){
        // do something with the $post_object
    }

    I hope this helps 🙂