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


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
    Madison Square Garden

    Concert 2
    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

    Radio City Music Hall
    101 Radio Hall Drive
    Manhatten, New York 00234

    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:

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.