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 am new to PHP, mySQL and scripting in general. I'm trying to design a WP custom post type which would be like a point on a timeline or an item on a resume. I'm having trouble designing the structure of the data in a nice, neat way. Each post or 'item' can be either dated or undated. If it's dated, it can either be an event, in which case it has one date attribute, or it can be a time span, in which case it has a start and end date. If it occurs over a span, that span may be 'ongoing', that it will end in the future and then the editor will come back and update the record to reflect that end date (e.g. the most recent position on a resume can be from a start date until the 'present'). The post can have content and other meta-information like a custom taxonomy, but I'm really concerned with boiling down these subcategories to the fewest number of meta fields in the WP postmeta table. The subcategories as I understand them are

  • Undated Events (!Start !End !Present)
  • Dated Events (Start !End !Present)
  • Ongoing Time Span (Start !End Present)
  • Completed Time Spans (Start End !Present)

Is this the best way to model these events/span/CV items?

Thanks!

share|improve this question

1 Answer 1

up vote 2 down vote accepted

If I understood you right, you need only two meta fields: start_date and end_date for your posts. Then you can compare current date to these fields and create (update) a taxonomy for the posts:

  • Undated, if the post have no both start and end dates;
  • Dated, if there only start date exists and current date is lesser;
  • Ongoing, if current date is between start and end dates;
  • Completed, if current date is greater than end date.

Each time somebody visits the site your theme or plugin function will check the dates and update taxonomies for posts where current date does not fit in it's taxonomy any more.

share|improve this answer
    
Thanks, that clarifies some things for me. I still prefer to leave the end date unspecified in ongoing events. All things come to an end, but it is nice to be optimistic. If I do include an option for marking the event as ongoing, does that mean I have to test for eight (2^3) possible combinations of inputs to determine which of the four types of events it is? –  Ryan Schram Mar 16 '13 at 20:42

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.