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
:
add_action(
'pre_post_update',
function($post_ID,$data) {
var_dump($post_ID,$data);
var_dump(get_the_category($post_ID));
die;
},
10,2
);
Proof of concept code only, obviously.
Related Posts:
- Hook when category is added to post
- How do the ‘tag’ and ‘category’ (default) taxonomies do ‘save_post’ action?
- Send an email when custom post type category is changed
- what is the action hook code to supporting product category condition in single product page of woocommerce?
- Remove word “Category” from WooCommerce product page [closed]
- Replace category titles
- functions.php conditional tag – only show in single.php?
- Set the default category of an attachment
- Assign category from custom field on post creation and update
- Add category only if post has custom taxonomy category
- How to hide category name
- Removing Uncategorized on post save if other category present?
- Categories widget show empty?
- Custom Meta Box (SELECT2) Not Saving Taxonomy Terms
- How to access deleted term inside delete_product_cat action
- How to hide a category or tag everywhere EXCEPT for use with get_posts
- Get Category in save_post Hook
- Correct Hook/Filter to amend category choices on post edit page
- How to delete WooCommerce categories in bulk that only have one product
- Ajax Category add doesn’t update the list table custom column
- How to hook into creating a category?
- How to display the category featured images [closed]
- Hook action when create new category [duplicate]
- Replace category titles inside RSS feed
- Get category of post inside save_post hook
- Could not insert term into the database
- How can I get category ID by category name?
- Randomise results from a category page?
- Adding Custom User Profile data based upon Categories
- Only show category to certain user levels without plugin
- Order posts by category name
- How can I make wp_list_categories output li with category-slug as class, for its children?
- Output link to category from WP_Query loop of woocommerce products
- Display name of the last child category
- If in category to be inside of a function
- How to exclude posts from a category when using this particular format
- Viewing category pages without the word ‘category’ in URL
- Different excerpt styles per category, but chronological
- Show only one category
- Pagination Not Working on Category.php page
- How to view WordPress’ default category IDs?
- Broken category pagination
- how to change template?
- Multiple Domain Names – One WP Install (non-Multisite) – Default Each Domain name to Product Category WooCommerce
- Hard coded main navigation
- one category template for multiple categories
- Display posts separated by Category in Author’s page
- How can I define a custom archive for childs of a specific category?
- Category shows only top level child categories
- The arrangement of categories always change while posting article
- REST API: Display Category names in JSON?
- List posts in alphabetical order
- Where is the category of a post stored?
- Categories list loop – add separator every 3 categories [closed]
- wp_list_pages() exclude category
- How to define multi categories posts number
- Get the ID of 10 Latest Pages stored in a WordPress Category
- how to separate categories in loop.php?
- How can i remove the posts category class names from body_class
- Different Category Headers using in_category and elseif
- related articles using shortcodes
- Show category meta in loop on homepage
- How to get selected taxonomy or category ID if using custom walker?
- How to hide widget from certain category
- Category link redirect to custom template page instead of index.php?
- Rebuilding a Site: How to Show Several Category Posts in Woo Framework Theme?
- the_category() doesn’t working in wp_query loop
- Displaying links to all posts of the same category on the post page
- Add class to current post in query_post
- separate posts to have (kind of) 2 blogs?
- create relationship between posts from one category and posts from another category
- save_post trigerred twice
- Sort posts by child category name
- Intermittent Gutenberg 504 Gateway Timeout when calling REST route to retrieve categories
- display specific category when website loads
- Automatically add custom taxonomy to posts in a category
- Category page 404s on mobile but not desktop?
- I want to create a custom taxonomy page showing a list of subcategories
- Displaying data from custom fields on a specific category page
- Get WooCommerce product category list in functions.php
- Excluding specific category from custom theme functions
- How to define a post category undeletable by other users?
- Displaying portions of multiple pages from a given category, in a single summary page
- Change wp_link_pages to link to another page
- Post url rewriting for posts with certain category
- Hide post category name wherever it might be mentioned
- Issue with WordPress category search
- wp_category_checklist won’t show up for non-admin users
- get_the_terms_list output last child only
- Exclude posts with certain tags in category archive
- How to loop through a custom field for each post, & display?
- How to add additional field to Add new category part (without plugin use) [closed]
- show category name before first posts in each category
- Need list of child category post titles sorted by child category
- Lowest catagory link
- How can I add a Categories page link to a menu? [closed]
- Media Library filter returns undefined function get_current_screen
- Way to show content of a post, but if exceeds character limit revert to excerpt?
- Display all subcategories for a product category in woocommerce
- Why does my WordPress index has a category?