Although the hooks are passing you the ID of the changed object in the parameter $object_id
, you aren’t using it and are calling get_the_ID
instead which will give you the ID of the current loop item.
Try changing your uses of $post_id
to $object_id
instead.
Related Posts:
- Send an email when custom post type category is changed
- Prevent function from triggering again when post in specific category gets another category?
- 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?
- Allow users to create their own feed from selected categories?
- Woocommerce get category image full size
- Order get_terms() By Custom Field
- Control term order on a per-post basis
- Fixing category count
- How can I get category ID by category name?
- Elegant way to add parent categories?
- 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
- what is the action hook code to supporting product category condition in single product page of woocommerce?
- 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
- Display empty taxonomy terms with get_terms()
- 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
- List Terms in Category
- Set post categories to include parents when setting child category
- How to get data about category in category.php
- Limit number of terms that a custom taxonomy can save per custom post type
- Inserting Category programmatically
- How can i insert term in a specific language of Polylang?
- Why does the argument list_only do on Walker_Category_Checklist::start_el?
- Display Posts Loop for each parent and for each Child
- Is There a Difference Between Taxonomies and Categories?
- Get posts from specific taxonomy term
- Get posts under a category with SQL
- Getting category URL with hyphens, not spaces
- get_terms function not returning anything
- wp_dropdown_categories not showing option as selected
- Ive got a term (get_term_by) but now I want to filter it by a category it is in?
- Get a count of how many times a term or a category is used in posts
- Get Categories Where Taxonomy Equals ‘n’
- Display sibling categories on category page
- Count tags for a specific category
- How to Link to Most Recent Custom Post of Same Term
- How to access deleted term inside delete_product_cat action
- Filter WooCommerce archive pages by an additional category
- Getting Category Children
- More efficient way to list posts by category [duplicate]
- Showing HTML if Post is In Certain Taxonomy Term
- Exclude categories by ID
- Using in ‘category_name’ in ‘$query->set();’?
- How to store category and tags separatly on wordpress?
- How to load several hierarchical categories from functions.php
- Post to inherit custom category background image from parent
- wp_delete_term or wp_delete_category?
- Update custom category fields front-end
- Combining these queries? (Same taxonomy term + same category as post)
- create function to call category name and slug
- WP-CLI Add category as menu item main-menu
- Add properties to term object
- get_object_term_cache duplicate terms after update to wordpress 6
- 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’?
- Replace deprecated get_category_children code with get_terms
- Can’t display posts by filtering categories using isotope.js
- How to remove parent category from child category url using wordpress rewrite rule?
- Get_term_meta() does not work with pre_get_posts()
- Restrict retrieved terms by category?
- List non-empty categories from a custom post type
- How to modify custom category field from front end?
- outputting taxonomy hierarchy
- Bulk Change WordPress category Slug
- 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
- Getting a sub category based on a category name
- 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?
- 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
- Issue on Listing Sub Product Categories In Woocommerce
- get_category_children/ the new get_term_children not work
- Taxonomy term RestApi data 10 rows limitions
- List the category tree of all the product_cat categories
- hide_empty property not working when using get_terms