0

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!

1 Answer 1

2

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.

1
  • 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? Mar 16, 2013 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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