Home Forums General Issues Relationship: Find posts related to another post in a repeater relation field


Relationship: Find posts related to another post in a repeater relation field

  • Hello Everyone! I have a post_type called ‘entity’, and it has multiples repeater fields with relationships, this is a real example: Business Connections in post ‘John Doe’, to add multiple job positions.

    — Business Connections (Repeater Field / Name: entity_business_connections)
    —— Is (Select Field / Name: entity_business_connections_is)
    ——— Owner
    ——— Shareholder
    ——— Member
    —— In (Relationship Field / Name: entity_business_connections_in)
    ——— Adobe (post_id: 1234)
    —— From (Date Picker Field / Name: entity_business_connections_datefrom)
    ——— 1989
    —— To (Date Picker Field / Name: entity_business_connections_dateto)
    ——— 2005

    And so on, there’s another 10 fields like Business Connections, and now I’m trying to make the reverse relation, just like ACF relationship tutorial show regarding Doctors. In this case, I want to show all ‘entity’ posts that has any relation to ‘Adobe’ in a organization-single.php, to show for example, Adobe Company:

    ‘John Doe’ was ‘Member’ (here, in Adobe) from ‘1989’ to ‘2005’.

    I was unable to find the right way to do this. Any ideas about how it should be? I’ll really appreciate if you could give me some hint!

    PD: I know this I’m trying its kind of dificult to do with ACF and you probably you will suggest me another way to do this, but in the meantime I need to try to solve this using ACF 🙁

    Thank you in advance! 😉


    Juan Pablo

  • Hi @juanpablob

    The above is very similar to another question here:

    The repeater and flexible content save data in the same way, so you will both end up with very similar code.

    Please read over the linked documentation articles to see how you can filter the WP_Query args and allow for sub field values int he meta_query.


  • Hey @elliot! Thank you very much for taking your time to answer this 😉 I have a last question: ACF creates fields in DB with same name but with a “_” as prefix, are they necessary? May I run a query to delete fields starting with a _ ?

  • Hi @juanpablob

    Yes, they are necessary. You can read more about them on the update_field documentation page.


Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Relationship: Find posts related to another post in a repeater relation field’ is closed to new replies.