I’m trying to figure out how to make a function to automatically add a “featured” tag to a post, based on a checkbox in a metabox I’ve added to the edit screen.
I think the function I need to use is wp_set_object_terms, but I don’t get how it works. I know how to check if those checkboxes are active or not, but that´s all.
I hope someone can put me on the right track with this.
I accidentally found this question searching for something similar, and I liked your approach, so I improved your code a bit.
wp_remove_object_terms
to be able to switch back ( toggle ) custom meta box value ( in this case check-box value ).function works fine with both, regular and custom post types, also can be used with tags, categories or custom taxonomies too.
Ok, found the problem.
This code works like a charm:
But it only works in standard post, not in custom post types. There is a hook to do the same with custom post types?
You can hook into the action with
add_action ( 'publish_post', 'your_function' );
Write a function to check if the checkbox is checked and if so update the posts term
http://codex.wordpress.org/Plugin_API