Support

Account

Home Forums General Issues Query relationship field in repeater field Reply To: Query relationship field in repeater field

  • Hi Elliot,

    Thanks for your reply. I had another question on this forum where you also suggested to use posts2posts. It looks like it’s the solution, but I don’t want to rely on another plugin (which has cancelled support). So I’m trying to find a solution with only using ACF.

    I have about 700 events and 8000 artists, so changing the relationship field to a post_object field isn’t an option. Then I’d have to select an artist out of a drop-down with 8000 artists…

    Every event can have more than 100 artist, so I hope my whole concept won’t be limited by performance issues.

    I did notice that I can put the Return Format from Post Objects to Post IDs. So on an event page, for each artist I can do:

    $artist = get_field('artist');
    foreach ($artist as $artist_id) {
    	echo get_permalink($artist_id);
            echo get_the_title($artist_id);
    	etc...
    }

    If I look at the way all the artists are stored in the DB for each event, it is:

    Array ( [0] => 10001 [1] => 10002 [2] => 10003 [3] => 10004 [4] => 10007 [5] => 10008 [6] => 10009 [7] => 17497 )

    Which looks much leaner than when I put the relationship setting to the return format Post Objects (because than it saves a lot more artist postdata in the array, which I don’t really need since I can get all postdata with just the ID).

    If I make a repeater field, in which I put a relationship field which has Return Format set to Post IDs, would that simplify my query? Is it then possible to find all events which have one particular artist post ID?

    Thanks in advance!