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'm at an impasse here. I'm admin-ing a food blog for a friend. She enters the ingredients for each recipe post as post tags. Down the road I'm going to create a page where a user sees a list of all ingredients in the database, they can check ingredients they have, and they'll get a list of recipes tagged with all those ingredients they checked.

The crux here is I need a way to describe each of those ingredient tags as ingredients in the database, so the query automatically lists those ingredients for the user.

Using custom fields doesn't seem to be the way to go because all the built-in WordPress functions will only list post_meta keys/values for a given post. Also, there's a lot of duplication, as there will be many instances of the same ingredient value, so simple MySQL queries won't help there. Also, entering those in the Edit Post screen isn't very user friendly with the default custom fields metabox, nor is it possible with the Advanced Custom Fields plugin.

I'd like to use something like the category metabox--a simple list with checkboxes and the ability to add a new ingredient to the list. When the user publishes the post, the tags in that metabox would somehow save to the wp_terms, wp_term_taxonomy, and wp_term_relationshiops tables with a unique identifier distinguishing it as an ingredient tag (its own taxonomy? use the term_order column? create a new column and use that?).

I've read about creating custom metaboxes, and I get how it's generally done; however, I'm not so savvy on how to customize what categories/tags are retrieved and listed, and how to customize the data it saves to the database, so I can ensure the tags being entered from that metabox are saved in a unique fashion.

Hope this makes sense. Maybe I'm overlooking an easy solution to this? Any help would be appreciated. Thanks.

share|improve this question
    
why not just create another taxonomy and make it hierarchical, like categories? –  Milo Oct 4 '12 at 15:14
    
I agree with what is said above. Create the hierarchical tax, and then stick it onto your "Recipes" custom post type - it'll appear exactly like Categories. –  Eric Holmes Oct 4 '12 at 15:39
    
Awesome! Yep, I was indeed overlooking this. Didn't know about this function. Thanks a heap :) –  Clinton Oct 4 '12 at 15:57
    
@Milo please add your solution as an answer so that question can be properly resolved. –  Rarst Oct 4 '12 at 17:39
add comment

1 Answer

Create a hierarchical custom taxonomy via register_taxonomy, which will function the same as the built-in Category taxonomy.

share|improve this answer
add comment

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.