Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
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 :) –  Michael McGarrity Jan 31 '13 at 11:12

1 Answer 1

up vote 1 down vote accepted

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
share|improve this answer
    
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. –  Michael McGarrity 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? –  Michael McGarrity 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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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