You would use the save_post hook, in your hooked function use wp_insert_term as described here:
http://codex.wordpress.org/Function_Reference/wp_insert_term
Then use wp_set_object_terms on the post to assignt he taxonomy term you just created as follows:
http://codex.wordpress.org/Function_Reference/wp_set_object_terms
for example:
function my_save($post_id) {
wp_insert_term( 'bannanapost', 'fruit');
wp_set_object_terms( $post_id, 'bannanapost', 'fruit', true )
}
add_action('save_post','my_save');
The above code, placed in functions.php of your theme, would add the term ‘bannanapost’ to each post when saved, in the fruit taxonomy
Related Posts:
- Better way to enforce category hierarchy in post_categories_metabox?
- Add additional data to a specific taxonomy term when used in a post
- How to show a hierarchical terms list?
- The Difference Between Hierarchical and Non-Hierarchical Taxonomies?
- How to perform unit testing on proposed patches in Trac?
- Attaching taxonomy data to post with wp_insert_post
- Need a simple but complete example of adding metabox to taxonomy
- How to get taxonomy term of the current page and populate queries in the template
- Can I add a Category Metabox to attachment?
- Can the default “post tags” taxonomy be renamed?
- Custom columns for taxonomy list table
- Custom Taxonomy as checkbox or dropdown
- Custom Taxonomy WP_Query for All Terms in a Taxonomy?
- Custom taxonomy list page?
- How to add a default item to a custom taxonomy?
- Remove the category/taxonomy description field?
- Taxonomy dropdown metabox in the back-end
- How can I create a taxonomy meta-box with search suggestions but no new terms input?
- Add ‘Description’ to taxonomy ‘Quick Edit’
- Why does get_term() require taxonomy? Are term_ids not unique?
- How does Woocommerce store variation attributes, and how can they be retrieved per-variation? [closed]
- tax_query in get_posts() not working?
- How to display non-hierarchical taxonomy as terms with checkboxes?
- What is wp_insert_term “alias_of” arg for?
- Automatically Assign Parent Terms When A Child Term is Selected
- get term by id without taxonomy
- Custom taxonomy hide meta box but show in menu
- Custom Post Type – Taxonomy Dropdown Menu?
- How to organize and cache additional data associated with terms?
- Using pre_get_posts to set posts per page, how do I?
- get a specific taxonomy term name
- wp_set_object_terms() Fails to Set Terms
- wp_set_object_terms() — prevent overwrite?
- How to group meta boxes on the post edit page
- Taxonomy terms sort by… Last name!
- List Hierarchical Term List with Count with Related Term
- Is there a way to set singular/plural labels for taxonomy term names?
- WordPress – Creating multiple versions of the same single-customtype.php depending on selected taxonomy categories
- get_terms() How many is TOO many?
- Exclude custom taxonomy from search results and archive pages
- Child Terms not Displaying on the Taxonomy Term Admin Screen
- get_terms with posts that have a different taxonomy with term x
- Admin Panel – Disable Moving Selected Terms To Top of Metabox
- How to display child term of current term’s parent taxonomy?
- List all taxonomy terms / Show links if posts are attached, else names
- List taxonomy terms as links
- check if tag exists in wp database
- Sorting custom taxonomy causes menus error
- How to overwrite a specific parameter in a core taxonomy?
- Set a cookie in WordPress, using a select form and Jquery
- How to add terms to taxonomy with wp_insert_terms?
- How to update taxonomy custom field with wp_update_term()?
- Get_term_by only returns one item from array
- How to set a Preset category for custom post types?
- Can we have same term slug in different taxonomies?
- Is there any difference between post in child term and child & parent terms?
- Set default (auto) slug prefix for Tags
- How to have “the most used tags” taxonomy always expanded?
- Add Thumbnail to wp_list_categories()
- Get parent and first child taxonomy terms?
- Display the number of published posts for each custom taxonomy term?
- Display Custom Taxonomy in Sidebar in Two Columns
- Get wordpress taxonomy archive and sort by year
- Search for tags
- Create and move terms for taxonomies
- Display Post by taxonomy and taxonomy child
- Display Post by taxonomy and taxonomy child if exist
- Fatal error: Call to undefined method stdClass::filter() in wp-includes\taxonomy.php on line 805
- WP native tag suggest metabox. How does it process tag id?
- Missing term_id and term_taxonomy_id when adding a term using wp_insert_term() function
- Update all posts at once
- Change order of WordPress tag cloud
- Retrieve taxonomy terms in order of their post’s date?
- How to get the last term from taxonomy?
- Count posts for each taxonomy term for each month
- Custom taxonomy archive – No posts found [closed]
- Display parent taxonomy name and list child taxonomies below it?
- List post from current taxonomy children
- What hooks/filters are there to alter selected terms on post save?
- Count argument in get_terms has no effect on ouput/doesn’t work
- Filter blog archive by category in URL
- How can I remove links from the function “get term list”?
- Alphabetical order in taxonomy.php
- Get Term names from WP Term Object
- tax_query: What to pass when I want to have all terms?
- Custom Roll/Custom Post Type – Can’t Select Categories
- Let users create a new custom taxonomy entry from frontend (without creating a post)
- Get the term for an taxonomy archive when the term has no posts
- Consolidate Metaboxes into 1 Big Metabox
- Trying to list terms of a custom taxonomy using get_categories
- Add a term to an attachment submitted from front end
- orphaned taxonomy terms remove by sql query
- functions to create term and child terms
- Get and loop posts with all taxonomy terms
- Unable to delete a Category and Tag that share same slug
- base directories / URL
- Get current custom user taxonomy
- Conditional tag affecting taxonomy term and its children?
- WordPress REST get all items without a taxonomy assigned
- Custom template for archive of a custom taxonomy