Don't clear taxonomy data on post update
When updating a post that has taxonomy data associated with it, the taxonomy relationships are lost. I've only noticed this happen with wp_update_post() and wp_trash_post() functions, though surprisingly not wp_delete_post() and wp_trash_post().
The only way I can solve it is to fetch all the taxonomy data on a post before updating. If using the wp_update_post() function you can re-apply the taxonomy relationships at the same time as calling wp_update_post() using the tax_input argument. Otherwise you have to re-apply the taxonomy relationships afterwards via wp_set_object_terms().
It would be ideal if the taxonomy data didn't get wiped at all unless explicitly instructed to do so. If this fix isn't possible could you at least fix it so that it automatically fetches and temporarily stores the taxonomy relationships before the update and re-applies them afterwards?
The only other mention of this issue I've seen is here: https://wordpress.stackexchange.com/questions/110210/how-to-prevent-loss-of-custom-taxonomy-when-calling-wp-update-post
So ... have you tested to make sure it's not your theme or plugins?
Well that's odd. It's not doing it at all now. So whatever I did most recently has fixed it. To test, I called wp_update_post() without first fetching the taxonomy data and also tried the TwentyFourteen theme with plugins disabled works everywhere now :S
No worries :) That just sounded SO weird that I felt if it was widespread, someone would have screamed already ;)
In general, stuff like that is a bug, so you should always test on a clean build first, and if you can reproduce it, report to trac. Though that's why I monitor this forum to catch those and pass them up when needed ;D
RSS feed for this topic
You must log in to post.