I have a function hooked to the save_post hook. this function is mostly concerned with the categories that the post is in. My function does the following:

function post_save_hook($post_id){
    $categories = get_the_category($post_id);
    foreach($categories as $category){
        //Handle this category

Say I have a category called featured, and a post was published under this category. then the same post was edited and removed from the featured category, in this case my function won't detect this change.

So what I want is to know if this post was in some category and removed from it.

  • When do you need to know? Do you need a long term record, or do you just need to know when the category is removed?
    – s_ha_dum
    Commented Jun 3, 2014 at 13:41
  • No, I just need it this one time that the post was removed from this category. Commented Jun 3, 2014 at 13:52

1 Answer 1


save_post runs too late to do what you are trying to do. That hook fires after the post and related meta data are stored. The category has already been removed at that point, and WordPress keeps no record.

You will need to hook into the save process earlier, perhaps pre_post_update:

  function($post_ID,$data) {

Proof of concept code only, obviously.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.