2

Here's what I have right now:

Custom Post Type for a list of Draft Beers Available. These Drafts are updated frequently.

I've set it up so that each draft beer is paired to a draft line number. ex. 1 - coors, 2 - Bud, 3 - Labatte, etc.

Right now, you can easily update what draft beer is on which draft line by updating the existing custom post(draft). ex. 10 lines with 10 posts and user updates each one.

I have it set up to Time Stamp when it was updated.

Here's what I want it to do:

I want each draft line(number) to have it's own history. Basically, each draft line would be it's own CPT in a way in that it has a collection of posts(drafts) but only shows the most recent unless searched or viewed.

But do I have to create a custom post type for each draft line? I'm hesitant because there are about 45 draft lines.

Is there a better way to achieve this? Would a child-term or child category achieve this?

Here's what I know:

  • Could you please clarify terminology (draft beer?.. draft line?..) for people clueless about beer?.. :) – Rarst May 1 '15 at 20:07
  • @Rarst sure, say there are 10 draft beers available. Draft just means the kind you put into a glass, out of a keg. So no cans or bottles. There are 10 lines that connect each Tap with each keg. – TFcuse May 1 '15 at 20:14
  • @Rarst I think those people have a very lonely life :-) – Pieter Goosen May 2 '15 at 9:02
1

I would probably go with a custom post type ( draught - the golden honey from the gods ) as you already have.

I would then create two taxonomies, keg ( which can be a hierarchical taxonomy ) and line ( which can be a non-hierarchical taxonomy )with their respective terms.

Example :

  • keg

    • coors
    • bud
    • labatte
  • line

    • one
    • two
    • three

The reason for keg being hierarchical is that you can later have child terms under your parent terms which makes it easier to extend

Each time a new post is published, you can assign one term from each taxonomy to it. The advantage here is, you are looking for a system where you can keep records of previous pairings etc. You will not have this if you simply keep on updating the same post. Yes, you can work with revisions, but that is really not the way to go here

So what you should do is, create a new post everytime something changes in your line up and assign the appropriate terms to that specific post.

The only issue is going to be how you are going to display them on your home/front page ( I would opt for a static front page here). In my opinion, you will need to loop over each term in the line taxonomy and get the latest post from each term using WP_Query or get_posts. You would may be need to sort the results for them to be in numerical line order and you will need transients to store your results as it can become an expensive query to run

Here are some posts you might find useful in connection with the above

  • Custom sort order with get_terms -> This post uses get_users but you should be able to use this on get terms. I do thing it will be best first to create your tems in numerical order, one first and ten last, then you can simply use the build in sort by ID to sort your terms

  • Using transients -> In this post I have explained well with code how to setup and use transients to save on db calls and time.

I hope the above info makes sense

  • I'm not even worthy of such an excellent response ((bows down)). Thank you so much. Static front is a great suggestion because the beer list is really the only part that needs to be dynamic. And I don't trust those drunkards changing other stuff anyway. Thanks again, man. I'd like to buy ya a beer sometime. – TFcuse May 8 '15 at 17:48
  • My pleasure. Up for a beer anytime :-). Enjoy – Pieter Goosen May 9 '15 at 5:04

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.