wp_set_object_terms not updating database without a die()

by Aravona   Last Updated June 12, 2019 11:08 AM

I have added custom taxonomy to media attachments. From the individual post page these are updating correctly, with some tweaks to get the column count updating correctly - and I can see these changes in the admin/database without a problem.

In the media popup, I can change the taxonomy and using the edit_attachment action I can see wp_set_object terms is firing, I can also see that it returns an array with the correct IDs in for the updated term:

wp_set_object_terms($id, $cat_ids, 'attachment_category', false);
//returns
array(1) {
    [0]=>
    string(1) "3"
}

3 being the correct ID for the term in question, however I cannot see an update in the database and when I refresh the page or close/reopen the popup the change is reverted.

Why is wp_set_object_terms in this case not updating the database but thinking it is successful? edit_attachment is the only action which correctly fired for me when the save-attachment-compat action is triggered on the form. If I add a die(); at the end of my function, and stop any further changes, it updates the database, is this the correct behaviour?



Related Questions


Prevent Delete Attachment by URL or When Submit

Updated March 25, 2018 09:08 AM


How do I Make a Theme "plugin-ready"?

Updated August 01, 2019 15:08 PM


Remove action added in plugin class from theme

Updated October 09, 2018 11:08 AM