Skip to main content

How can I set taxonomy programaticlyprogrammatically

Tweeted twitter.com/#!/StackWordPress/status/145644985327419393
added 298 characters in body
Source Link
JasonDavis
  • 1.7k
  • 6
  • 36
  • 57

Here is my situation. I plan to distribute a theme I am working on and it has a custom post type called Code and it has a custom taxonomy called Languages now I also use a custom metabox with a dropdown list of available languages, I need to somehow make the value that they choose in the select dropdown box to not only save as the meta value (which it does already) but I need that value to also be picked as the taxonomy for that post

So If they make a post and pick the Language "PHP" in the meta_box, then when they post, it will make the "PHP" taxonomy be selected. I plan to hide the taxonomy UI and auto populate all the possible taxonomy terms

  1. How can I make a metabox value be saved in addition to a meta_value but also as the taxonomy for that post?

Update

Ok I have found a possible solution,wp_set_object_terms( 123, 'PHP', 'tag' ); will add a PHP tag taxonomy to post ID 123.

So I just need to know how to get a post ID when it is being posted, is that even possible as the post is not in the DB yet on a new post? Any ideas

Here is my situation. I plan to distribute a theme I am working on and it has a custom post type called Code and it has a custom taxonomy called Languages now I also use a custom metabox with a dropdown list of available languages, I need to somehow make the value that they choose in the select dropdown box to not only save as the meta value (which it does already) but I need that value to also be picked as the taxonomy for that post

So If they make a post and pick the Language "PHP" in the meta_box, then when they post, it will make the "PHP" taxonomy be selected. I plan to hide the taxonomy UI and auto populate all the possible taxonomy terms

  1. How can I make a metabox value be saved in addition to a meta_value but also as the taxonomy for that post?

Here is my situation. I plan to distribute a theme I am working on and it has a custom post type called Code and it has a custom taxonomy called Languages now I also use a custom metabox with a dropdown list of available languages, I need to somehow make the value that they choose in the select dropdown box to not only save as the meta value (which it does already) but I need that value to also be picked as the taxonomy for that post

So If they make a post and pick the Language "PHP" in the meta_box, then when they post, it will make the "PHP" taxonomy be selected. I plan to hide the taxonomy UI and auto populate all the possible taxonomy terms

  1. How can I make a metabox value be saved in addition to a meta_value but also as the taxonomy for that post?

Update

Ok I have found a possible solution,wp_set_object_terms( 123, 'PHP', 'tag' ); will add a PHP tag taxonomy to post ID 123.

So I just need to know how to get a post ID when it is being posted, is that even possible as the post is not in the DB yet on a new post? Any ideas

deleted 124 characters in body
Source Link
JasonDavis
  • 1.7k
  • 6
  • 36
  • 57

Here is my situation. I plan to distribute a theme I am working on and it has a custom post type called Code and it has a custom taxonomy called Languages now I also use a custom metabox with a dropdown list of available languages, I need to somehow make the value that they choose in the select dropdown box to not only save as the meta value (which it does already) but I need that value to also be picked as the taxonomy for that post

So this isIf they make a 2 part questionpost and pick the Language "PHP" in the meta_box, then when they post, it will make the "PHP" taxonomy be selected. I plan to hide the taxonomy UI and auto populate all the possible taxonomy terms

  1. How can I make a metabox value be saved in addition to a meta_value but also as the taxonomy for that post?

  2. When a user install my theme, how can I pre-populate the taxonomy with a set of values?

    How can I make a metabox value be saved in addition to a meta_value but also as the taxonomy for that post?

Here is my situation. I plan to distribute a theme I am working on and it has a custom post type called Code and it has a custom taxonomy called Languages now I also use a custom metabox with a dropdown list of available languages, I need to somehow make the value that they choose in the select dropdown box to not only save as the meta value (which it does already) but I need that value to also be picked as the taxonomy for that post

So this is a 2 part question

  1. How can I make a metabox value be saved in addition to a meta_value but also as the taxonomy for that post?

  2. When a user install my theme, how can I pre-populate the taxonomy with a set of values?

Here is my situation. I plan to distribute a theme I am working on and it has a custom post type called Code and it has a custom taxonomy called Languages now I also use a custom metabox with a dropdown list of available languages, I need to somehow make the value that they choose in the select dropdown box to not only save as the meta value (which it does already) but I need that value to also be picked as the taxonomy for that post

So If they make a post and pick the Language "PHP" in the meta_box, then when they post, it will make the "PHP" taxonomy be selected. I plan to hide the taxonomy UI and auto populate all the possible taxonomy terms

  1. How can I make a metabox value be saved in addition to a meta_value but also as the taxonomy for that post?
Source Link
JasonDavis
  • 1.7k
  • 6
  • 36
  • 57
Loading