I am working on a form where I am trying to insert a term to a taxonomy. So I have a drop down select with a list of my taxonomies and then the next field is a simple text field where the users will enter the name of the term.

Now this is where I am trying to figure out how to use a hook or some type of action when the user hits the submit button. I would like for the hook to add a term to the taxonomy that they have selected from the drop down select field.

So if they pick the cow taxonomy it will add a term to that that taxonomy, if they select the chicken taxonomy I would like the term to be added to that taxonomy.

Thanks for any direction or help.

  • 1
    can you edit your question to include the code? There are no technical details about what you have so far, and there is no generic forms API in WordPress
    – Tom J Nowell
    Commented Oct 24, 2022 at 13:15
  • Tom, I will admit I not sure 100% what I need. Here is my form in very basic format Select Box - Options are dynamically grabbed from my custom taxonomy of Department which right now has the options of Beef, Sheep, Goat, Swine Text Box - this is a plain text box that an end user will just type in information just as Novice, Junior, Senior, etc... Once the end types in the new term (Novice, Junior, Senior) they then will hit the submit button to commit the new term being saved to the taxonomy selected above.
    – spyfly
    Commented Oct 24, 2022 at 19:37
  • I am not a hard core coder but I am thinking something like... the syntax is not fulling correct but you give you a ballpark idea what I am trying to do function add_to_custom_taxonomy_term( $term_id, $tt_id, $taxonomy ){ // do some stuff $taxonomyfromselectfield (use this taxonomy from the drop down select field, then make term from the text field) } add_action( 'create_term', '$term_name_from_text_field', $taxonomyfromselectfield, 3 );
    – spyfly
    Commented Oct 24, 2022 at 19:58
  • please edit your question to include the code, don't post it in the comments as comments don't support multiple lines of code. There's an Edit link under the tags. If you are working on something and want to know how to extend it, we need to be able to see the thing you want to extend, so share it, and if you're not sure which part to share, start with the entire thing.
    – Tom J Nowell
    Commented Oct 24, 2022 at 21:35


Your Answer

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