When dealing with this, it turned out that the $parent var had to be casted as an int. Looking at the function wp_set_object_terms, it tests the param $parent with is_int(). The var $parent was coming from $_POST which was sent though http post using ajax.
Somewhere along the way, probably on the javascript side, my int $parent was being casted as a string. I’m presuming a new line character or something was being added to the var thus making php think it was a string.
Solution was then to cast the var $parent as an int like so: (int)$parent
So changing the last line to
wp_set_object_terms($id, (int)$parent, "warehouse");
Solved the problem 😉
Related Posts:
- get_the_term_list without links in 3.1
- Inserting terms in an Hierarchical Taxonomy
- How to prevent new terms being added to a custom taxonomy?
- get_term_children for immediate children only (not grandchildren)
- Is there a way to ‘Lock’ a Taxonomy?
- Creating a non-removable taxonomy term
- Get value in custom field with taxonomy [closed]
- Get second level terms of custom taxonomy
- Return only the custom sub-term for custom post type, do not echo term-parent
- wp_insert_term is adding a term that has no name
- Get terms from multiple taxonomies
- Formating the_terms() function output
- get_terms showing link to category even if all posts are drafts
- Determine if Term has Grandparent/Great-Grandparent
- Non-hierarchical custom taxonomy using checkboxes on edit-screen -> saving issue
- Retrieving custom taxonomy in order, but excluding specific tax IDs
- Get main parent categories for a product
- get taxonomy terms for parent and child
- Taxonomy query for children of parents
- show term description instead of list terms of custom taxonomy
- Separator for multiple terms
- Contact Form 7 – Populating dropdown list with terms relative to the post
- get_the_term_list without specific category
- Ordering Posts with Custom Taxonomy Terms Array
- How to create a theme template for the taxonomy “root”
- Checking if a Page has an Associated Term?
- What are terms and taxonomy, how they related to post and how these three are stored in database?
- Get multiple term objects by ids
- Echo custom taxonomy term name
- How to handle “the_terms” inside loop
- Display the Terms from a Custom Taxonomy Assigned to a Post(inside the loop) in Hierarchial Order
- How to create drop down for child categories of current taxonomy being viewed?
- Edit post meta with checkboxes on front end
- How to dynamically add custom taxonomy terms as a sub-menu of an existing menu item, using custom walker class
- Get terms ordered by post date
- Why does WP rename similar “term name”-slugs in separate taxonomies?
- Get Bottom Most Level Taxonomy Terms?
- How can I get WP to build a feed based on multiple taxonomy terms
- get_terms in a taxonomy template
- Set custom post type terms by id without knowing taxonomy
- Display hierarchical subterms of custom taxonomy based on depth
- How to determine the depth of a term in a custom taxonomy?
- get_term_children doesn’t return an array of children terms
- Get Current Custom Taxonomy ID by Post ID
- Use get_the_terms to list subcategories of custom taxonomy
- Term count by user
- AJAX response, edit tags
- List child terms if parent but show nothing on children
- Display Taxonomy Terms in an option tag with value being the slug
- If post has ANY term attached to it, get the first one only
- How to add contents of a custom field to a taxonomy term list?
- Sort order by slug for looped child terms of custom taxonomy
- Updating / Saving items generated by wp_terms_checklist on frontend
- Rewrite rules for varying nested terms of custom taxonomy
- List Posts For Terms Of A Custom Taxonomy For Any Post Type
- Query posts from a child taxonomy term id
- get_terms() duplicate first term of a custom taxonomy
- Count Number of Posts in Taxonomy Term in Last 24 Hours
- Update table wp_term_taxonomy.count after INSERT INTO via SQL
- How can I reduce amount of ifs and else ifs in this specific block of code?
- Get all attachments by custom taxonomy – term
- Echo custom taxonomy slug
- Get terms that don’t belong to current post with a shortcode
- Admin (All posts) stop responding problem
- Remove a href from this code
- How to get posts that contain multiple terms from multiple taxonomies?
- Cannot delete or edit a single term in a custom taxonomy, taxonomy name is wrong?
- How to check if a post has at least 2 terms from a custom taxonomy attached?
- How best to store data (URLs and IDs) extracted from posts and pages using custom taxonomies
- Get name of taxonomies of current page
- delete term from taxonomy and assign in new one
- export and import taxonomy terms from one taxonomy to another
- Find terms in a custom taxonomy based on the hirearchy
- Wp_query…a type of term a different div
- Adding Child Terms Programatically – No Warning but No dice either
- Show single Child Category on Custom Post
- Unsetting post_tag taxonomy breaks term description for other taxonomies
- Pull data from MySQL and add it to terms
- Get custom taxonomy terms that contain posts that have another taxonomy term
- wp_insert_post not adding taxonomy (using wp_set_object_terms)
- Filter “get_terms” query
- generate random slug when adding taxonomy
- How to filter a taxonomy meta field to the ‘single_term_title’ filter hook
- Custom order of taxonomy using wp_get_object_terms and woocommerce_term_meta
- Custom post type term names with ampersand in the term name
- If page is a taxonomy do X, if is a term, do Y
- Query pages by child term
- Getting the parent terms adds additional empty markup [closed]
- Display taxonomy term slugs
- Custom taxonomy list in two columns
- Tax query array terms display out of order
- Taxonomy term breadcrumb; how?
- Insert term description programmatically into hierarchical custom taxonomy
- get multiple values from $_GET from multiple checkboxes
- Get post terms with hierarchical relationships
- Unable to display the post titles in a drop down
- Taxonomy archive link from term id
- How can I get the term_id from the action hook ‘set_object_terms’?
- Taxonomy Child Not Updating Unless I Click Update Twice
- post_type_link not working for posts without terms