Use the hooks added_term_relationship
and deleted_term_relationships
. These only fire when the relationship changes, as opposed to set_object_terms
which always fires:
function wpse_181090_object_terms_updated( $object_id ) {
static $did = array(); // This function might fire multiple times for the same object, ensure it only runs once
if ( ! isset( $did[ $object_id ] ) ) {
$did[ $object_id ] = true;
// Your notification code
}
}
add_action( 'deleted_term_relationships', 'wpse_181090_object_terms_updated' );
add_action( 'added_term_relationship', 'wpse_181090_object_terms_updated' );
Related Posts:
- what is the action hook code to supporting product category condition in single product page of woocommerce?
- Action hooks returning old category instead of new category
- How to access deleted term inside delete_product_cat action
- Modify functions.php to add a term ‘uses-theme’ set to theme name on post save
- Is There a Difference Between Taxonomies and Categories?
- Check if a post is in any child category of a parent category
- How to export and import taxonomies (category, tag and/or custom taxonomy) and their terms
- get_terms vs. get_categories: does it matter?
- Woocommerce get category image full size
- Control term order on a per-post basis
- Fixing category count
- get_terms name__like list categories according to letter
- Elegant way to add parent categories?
- How can I select a primary category?
- Programmatically create product category and add thumbnail in woocommerce
- How to order the get_categories result
- Are Categories, Tags and Custom Taxonomies any different in regards to SEO?
- Excluding posts from a category but only if they’re not in multiple categories
- Update term count using a callback function
- Get terms that are associated with products from current category
- Does WordPress Offer a Way to Find All of the Categories that Don’t Have Children?
- Add custom taxonomy terms to WordPress menu dynamically & append #slug to url
- Removed slug from CPT, now How/where do I hook the filter to the taxonomy term archive pages link?
- Getting the sub category
- Use get_term_children to get the sub category of a parent category for the current post
- Update wordpress post terms programatically
- Display empty taxonomy terms with get_terms()
- Remove word “Category” from WooCommerce product page [closed]
- Get a list of Terms for a specific category
- When to use ‘get_category_by_path’ vs. ‘get_term_by’ to get category object from `get_query_var( ‘category_name’ )`?
- How to add custom script to the particular Product Category page
- Hide posts of a certain category unless logged in
- Add title, post content, and category like add_post_meta and update_post_meta
- functions.php conditional tag – only show in single.php?
- How do I get a list of all categories that a given user has written blog posts for?
- How to get data about category in category.php
- Limit number of terms that a custom taxonomy can save per custom post type
- Insert term when page is published – avoid duplicates after edits
- How can i insert term in a specific language of Polylang?
- Assign category from custom field on post creation and update
- Display Posts Loop for each parent and for each Child
- Is There a Difference Between Taxonomies and Categories?
- Get posts from specific taxonomy term
- How to hide category name
- Getting category URL with hyphens, not spaces
- How do I prevent term from being created on create_term hook?
- get_terms function not returning anything
- Display custom taxonomy attached to the post on post single page
- Ive got a term (get_term_by) but now I want to filter it by a category it is in?
- What is the action hook that deletes a taxonomy term from the backend? And how to retireve the term id before deleting it?
- Get a count of how many times a term or a category is used in posts
- Get Categories Where Taxonomy Equals ‘n’
- How to Link to Most Recent Custom Post of Same Term
- Getting Category Children
- Showing HTML if Post is In Certain Taxonomy Term
- Exclude categories by ID
- How to load several hierarchical categories from functions.php
- Post to inherit custom category background image from parent
- Combining these queries? (Same taxonomy term + same category as post)
- create function to call category name and slug
- Add properties to term object
- get_object_term_cache duplicate terms after update to wordpress 6
- How to hide a category or tag everywhere EXCEPT for use with get_posts
- List taxonomy terms assigned to a post in hierarchical view
- Sort categories by custom field in WordPress admin
- How to get immediate children of a ‘term’ parent id through ‘get_terms’?
- Ordering terms whilst in loop
- Replace deprecated get_category_children code with get_terms
- Get WooCommerce product category list in functions.php
- Get_term_meta() does not work with pre_get_posts()
- Correct Hook/Filter to amend category choices on post edit page
- Restrict retrieved terms by category?
- List non-empty categories from a custom post type
- How to delete WooCommerce categories in bulk that only have one product
- taxonomy_edit_form_fields output after term fields
- Ajax Category add doesn’t update the list table custom column
- How to hook into creating a category?
- Add subcategories posts to the counts column at the admin’s categories list
- show only terms from parent category
- Categories and Tags Conflict after Woocommerce Installation
- Get category of a taxonomy for a queries object in a loop
- get_terms sort order with child categories of varying depth
- Getting Post Tags From Certain Categories
- Display List of Categories Within a Custom Taxonomy
- List Terms by category
- get_adjacent_post_link excluded_terms ignored
- How to add a new child category via an SQL statement?
- get categories the post was in and just been removed from
- Why is my post categories not displaying?
- exclude parents from the_terms
- Problem importing categories and sub-categories
- Use get variable when rewritten url in wordpress
- How to display the category featured images [closed]
- Issue on Listing Sub Product Categories In Woocommerce
- How can I get the term_id from the action hook ‘set_object_terms’?
- Hook action when create new category [duplicate]
- List the category tree of all the product_cat categories
- Replace category titles inside RSS feed
- hide_empty property not working when using get_terms
- delete_term is not working properly with add_action()