I was hoping to get some help with how I organise posts in WordPress.

I have 2 Custom Post Types called 'Places' and 'Events'.

In the Admin, I'd like to be able to create a 'Place' post and associate multiple 'Events' posts to this. So perhaps inside an 'Event' post, I can select a 'Place' post from a list to associate that 'Event' with that 'Place'.

Can someone explain how I would achieve this?

Would I have to look at Taxonomies?


Many thanks for any advice.

  • 1
    Please do some research on Custom Taxonomies and Custom Post Types, then ask a definitve answer. This is, as it currently stands, much too vague to answer. And I guess "User CPTs and CTs" won't help much, right?
    – kaiser
    Jan 30 '13 at 18:10
  • You're right. It's all very new to me this side of WP. Next time, I will do my research and then post something a little more coherent :) Jan 31 '13 at 11:12

Three methods:

  1. Don't use taxonomies at all, just store the ID of the associated posts as post meta
  2. Create a taxonomy, and remove the ability to edit/delete/create terms. Then use automation to catch the hooks for the creation, editing, and deletion of Place posts, and create/edit/delete the associated terms in the taxonomy.
  3. Use the Posts2posts plugin by Scribu, though this would require learning a new API and adding an additional plugin dependency

If your relational mapping is a 1 place can have many events, but one event can only have one place, then a fourth option becomes available:

  • Set the parent post of an event to its place
  • Yes, i would use solution #1 : add a custom field to the custom post Events, with a dropdown menu of all Places, and choose the Place related to the event (this will insert ID of the Place if the custom field), allowing you to get that data from the event to display ; or the display all Events associated to a Place by making a custom query with Place ID as value.
    – Simon
    Jan 30 '13 at 13:56
  • Just read Simon's comment :-) #1 does seem powerful. Is it possible to populate a custom field with posts from a separate custom post type? I've only ever used it for text input. Jan 30 '13 at 14:05
  • 1
    You would not store a post in a custom field, you would store a post ID
    – Tom J Nowell
    Jan 30 '13 at 14:06
  • Yes, sorry, my bad. I meant to say "a dropdown list of posts" - so a select menu with post titles that the user could choose from - thus associating an event with a place. Is this possible? Jan 30 '13 at 14:09
  • 1
    Yes thats certainly possible, and that plugin could indeed do the trick. If you're happy with this you could mark it as the right answer?
    – Tom J Nowell
    Jan 30 '13 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.