Your issue is last argument in wp_set_object_terms()
call. You are setting $append
to true
, so it essentially checks if input is already present and does nothing else.
You want it set to false
(which is also default) so that terms are forced to be same as input and difference (what you removed) is deleted from post.
Related Posts:
- What is the difference between terms and tags?
- Display tags belonging to a specific post type only
- Creating a unique, linked list of tags from a specific category?
- How to add class on term link?
- get_terms with more than x post count
- Strict tag list – user should choose only existing tags for posts
- Limit tag cloud terms by date
- Display custom list of tags in post/page editor with hooks
- how to filter each tag item?
- get_tags() return an empty array after added tags with wp_insert_term()
- merging terms programmatically while maintaining the count
- Add post tag without post id
- Show all videos by tag name
- Sort query_terms_list for post_tags alphabetically
- List latest post for each tag with a category
- Exclude Tags by Array
- How to take list of words and insert them as terms to become tags of a post
- How to include post count in this “get_tags” snippet
- Control term order on a per-post basis
- how do I get the tag name from tag id?
- Do tags have dates?
- Display tags in list without link
- How can you tie into the tag metabox?
- Display tags for current post in sidebar
- How important are WordPress tags for SEO purposes?
- how to limit and display tag?
- WP_insert_term how to insert multiple values as taxonomny term?
- Massive Tags Remove Using MySQL
- Quicktags on all textarea.. Not working on plugin?
- how to change # of tag posts on /tag page?
- How can I remove certain HTML tags from the RSS feed?
- Stop WordPress removing tags when switching from HTML to Visual (TinyMCE)
- Set homepage to only display posts from one tag
- Individual css class for each tag in wp_tag_cloud
- How to remove/hide the predictive autocomplete popup when I type in the tag/term metabox
- How to remove ‘noindex, follow, max-image-preview:large’ in search page WordPress 5.7 up
- Displaying Posts by tag dynamically in WordPress
- How to rename ‘TAG’ to ‘TOPIC’
- How to not show tags if the post doesn’t have any?
- Don’t show a tag on a post if it is the only post with that tag
- Must Use Plugin Causing Query Error
- Remove the last character from tag name in tag archive page
- How to Override “Blog pages show at most” in tag.php [duplicate]
- Return post tags with description
- How to display tag cloud without links
- Get tags for post_type
- Line of Tag information Is Formatted Strange
- How can I make an auto-fill search box auto-completing with the tags?
- Get posts inside Get terms problem
- woocommerce product tags display
- Please help me to figure out how to display my tags
- Cross Site Related Posts?
- List tags by certain letter issue with special chars like å, ä and ö
- Strip and tags from a specific div
- Require tags for bbPress topics [closed]
- How to enable all Tag Descriptions in loop?
- WordPress Tag Page Hook?
- How can i order get_the_tags?
- For each loop on every word in post
- “ Language notation in the post content
- Default post_tag for custom post type
- WordPress tags as twitter sharer URL hastags
- Get Tag Slugs that start with a word
- Print_r displaying two different post->ID if placed in sidebar or single.php
- Detect tag page and include an Image for that specific tag
- Buddypress – Adding Tags in Profile
- Do not run this code on posts with a specific tag!
- Automatically add tag (first 4 characters) to uploaded media
- How can I automatically hyperlink tag names that are in my post body to the tag page
- wp-cli error: “Term is missing a parent”
- Add a specific tag to default tag list
- Random tag in the post
- Remove little gray box from content page
- Get the publish date of the older post inside a tag
- How to test if the tag list is empty for the current page?
- Replace -tag in the_excerpt
- Get X post tags
- Insert text BEFORE the “tag” title
- Title tag come up differently on search results
- Why doesn’t the_tags( ) accept empty string for first argument?
- tag based subscription
- Create multidimensional array of taxonomies
- Remove parentheses from tag cloud count
- the_tags outputs before echo
- Only display posts with a specific tag
- Prevent tag creation on the post edition page
- showing tag beside catagory
- How to get several fields from wp_query?
- Conditional tag for attachment posts
- Get multiple tags by slug
- How To get a list of popular tags by post views?
- Post order by selected tags
- WordPress editor, change code wrap (bbpress?)
- post specific tag cloud, how to display in descending order from popular to less?
- Tags as autocomplete values
- Need to return all tags – including empty ones – in list
- How do I exclude categories from get_tags?
- How to have H1 for site title only on Homepage?
- Custom message if tag returns empty results
- WordPress Title Tag Not Changing