0

I've created a custom taxonomy for my posts, and I was wondering if there is a way to add an extra input field (a text input) for every taxonomy term inside the edit post panel.

What I want is not a simple taxonomy meta field, because meta fields are always the same for each term in each post. Here's an example of what I want.

Let's say I have a taxonomy called "personality", and the terms are:
- cheerfulness
- lazyness
- extroversion
I want to be able to add a score to everyone of these terms, but different for every post. For example, post number one called Mark has
- cheerfulness 10
- lazyness 5
- extroversion 8
Post named Mary
- cheerfulness 2
- lazyness 9
- extroversion 3
etc.

To achieve this I think I should have an input field next to every taxonomy term. Too complicated? I guess new database tables must be created in order to do this. Any idea? Someone ever did something like this?
Thanks!

1 Answer 1

0

This is not a taxonomy field you need, because as you described, the name of the field will stay constant for every category, but its value will change for every post. So the field should be attached to the post, not to the category. What you actually need to use is a post custom field, that you could name (internally) something like _post_cheerfulness, _post_lazyness, etc. (The display names will of course be Cheerfulness, Lazyness, etc.). If your list of categories to be voted for will remain constant, this is extremely easy : you just need to create as many custom fields (possibly with meta boxes to make it look nice, maybe even with a star-rating system). If your list of categories will change all the time, it will be more complicated. But it's still achievable (with a dynamic custom field metaboxes generator that can loop through all categories).

5
  • Thanks barakadam. Then I guess I can connect each post custom field to each taxonomy with a meta field assigned to the taxonomy, right?
    – She Hulk
    Dec 10, 2012 at 12:16
  • The name of your custom post field does that for you. Naming it _post_cheerfulness, you can strip off "_post_" and get the name of the term : "cheerfulness". Or you could use another prefix, like _rate_cheerfulness, etc. You only need to stay consistent with your own naming convention.
    – barakadam
    Dec 10, 2012 at 12:47
  • You're right. Why do I always complicate everything? :P
    – She Hulk
    Dec 10, 2012 at 12:58
  • So is this the right answer for you? Keep us posted.
    – barakadam
    Dec 10, 2012 at 13:46
  • yes, sorry, I forgot to check it :)
    – She Hulk
    Dec 10, 2012 at 15:19

Your Answer

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

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