Support

Account

Home Forums General Issues How to get a foreign key to another group of fields

Helping

How to get a foreign key to another group of fields

  • In WordPress, I want to list events like concerts at Madison Square Garden or Radio City Music Hall.

    Let’s say I input this data in the backend (wp-admin)
    Concert 1
    Date
    Time
    Madison Square Garden

    Concert 2
    Date
    Time
    Radio City Music Hall

    In another section I want to have the Venues listed
    Madison Square Garden
    1000 New York Drive
    New York, New York 00823
    http://www.msg.com

    Radio City Music Hall
    101 Radio Hall Drive
    Manhatten, New York 00234
    http://rcmh.com

    When I list the Concerts in the front end, I want to also show the address

    So my question is…

    How do I reference the Venue info in the input (from a select box)
    Then how to I bring in all of the location data?

    Is there a post or doc that already outlines this scenario?

    I’m basically looking for a foreign key to the venues list.

  • Hi @dhobson98

    No worries. This kind of connection can be made with the post_object field.

    For each Concert, you need a post_object field to select a ‘location’.

    Then when you are rendering the HTML for your concert, just load in the location post object based on it’s ID.

    You can find examples for this here:
    http://www.advancedcustomfields.com/resources/field-types/post-object/

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

The topic ‘How to get a foreign key to another group of fields’ is closed to new replies.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.