Home Forums General Issues Accessing an image from a repeater based on post object field Reply To: Accessing an image from a repeater based on post object field

  • I am having a hard time working out how things are related by reading your description.

    Assuming that I understand, you would need to loop over every row of the repeater on the options page until you found the correct row. As an example

    $post_id = get_the_ID();
    if (have_rows('repeater_on_options_page', 'options')) {
      while (have_rows('repeater_on_options_page', 'options')) {
        if (get_sub_field('post_object_field', false)) { // using second argument of false here to get just the ID
          // this is the row we want, get the image field and show it
          // your code here .....
          // after we show an image there is no reason to continue
          // so break out of loop

    Seems complicated, why not just put the image field on the product page instead of needing to go to a different location in the admin to edit it? Also, your setup will not scale. I have many product you are doing this on then 1st the repeater will take forever to load and second it will slow down the site as you loop over more and more rows of the repeater because a query to the options page must be done for every row. This could be somewhat fixed on the front end by auto loading the values on this options page, but then you have the potential of an out of memory condition if the repeater grows too large.