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 have a custom post type ('Model') for a sports modelling agency, and it requires the model to enter sports they are competent at, and also rank their ability from 1 to 5. For example, given the information:

Model: Joe Soap.
Football: 4.
Archery: 2

I would store this in the custom_post_type 'model' with the fields:

Model Name: Joe Soap.
Sports: Football, Archery (taxonomy).
Rank: 4, 2.

How do I associate 4 with Football and 2 with Archery using a metabox, where different models may have different sports in their lists ?

share|improve this question
    
hm... I misunderstood your initial question. Store "rank" as a multidimensional array (into a option), like $rank[sports_taxonomy_term][rank_value] –  onetrickpony Jan 11 '11 at 20:41
    
That sounds like what I need - can you be more specific, or point me to a tutorial/documentation on how to do that within a custom post? –  Amanda Jan 11 '11 at 21:00
    
first, create your rank metabox (the form that gets the values) and post the code here... –  onetrickpony Jan 11 '11 at 21:11
add comment

3 Answers

up vote 1 down vote accepted

Your question is focusing on the wrong thing. A metabox is just one way for a user to introduce some data. The more important question is how you should store that data in the database.

You could make 'sport' a custom post type and connect it to models using the Posts 2 Posts plugin. Then, for each connection, you can associate a 'rank' custom field:

https://github.com/scribu/wp-posts-to-posts/wiki/Connection-information

The plugin takes care of creating a metabox and of storing the values in an efficient manner.

share|improve this answer
add comment

add_meta_box() documentation in Codex has example of metabox creation and links to related tutorials.

share|improve this answer
add comment

This tutorial on adding custom meta boxes is also really good: http://webdesignfan.com/custom-write-panels-in-wordpress/

It's all very flexible; you should be able to reuse the code you create.

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.