[wp-trac] [WordPress Trac] #16593: wp_set_object_terms not creating links when in a save_post action
WordPress Trac
wp-trac at lists.automattic.com
Fri Feb 18 19:30:21 UTC 2011
#16593: wp_set_object_terms not creating links when in a save_post action
---------------------------+-----------------------------
Reporter: grandslambert | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.0.5
Severity: normal | Keywords:
---------------------------+-----------------------------
I have a custom post type and a custom taxonomy for a recipe plugin. The
edit page for the post type has a meta box where ingredients are added,
and the ingredient name is the custom taxonomy. I have a hook into the
'save_post' action that then calls a function to save the ingredients.
Within that function is code to loop through and either match an existing
term, or create a new term in the taxonomy. This part works without a
problem. While doing this, I create an array of data related to the term
to use in wp_set_object_terms().
I then call:
`wp_set_object_terms($post_id, $postIngredients, 'recipe-ingredient',
false);`
where $post_id is the ID of the post, and $postIngredients is the data I
collected earlier. I have tried an array of term IDs, names, and slugs,
all with the same result. Even though wp_set_object_terms() returns a list
of "affected" IDs, the data does not appear to be saved. When I go back to
the edit screen for that post, it does not show an updated list of
ingredients.
The code is included in the RecipePress plugin and appears in the /classes
/recipe-press-core.php file.
I also have an importer and front end form that uses the same function to
save the ingredients. Both of these do exactly what they are supposed to
do. It just does not work when the function is called from the 'save_post"
action.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/16593>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list