Problem: I have a Form that edits posts, which includes a custom field. I would like to automatically set a taxonomy term on the post when the Form is submitted. The term should be determined by the value of the custom field.
Solution: Use the function wp_set_object_terms to set a term on a post:
wp_set_object_terms($post_id, 'term-slug', 'category', false);
Instead of term-slug you can use:
A single term slug, single term id, or array of either term slugs or ids. This will replace all existing related terms in this taxonomy. Passing an empty value will remove all related terms.
The last parameter false will delete all the other category terms from this post. If you use true instead of false, the existing category terms will not be deleted.
Das Forum „Toolset professionelle Unterstützung“ ist für neue Themen und Antworten geschlossen.