After much trial and error, I have found a solution that will allow wp_set_object_terms to be used. Despite already checking if my strings were integers, apparently I needed to convert the array explicitly as well. So I changed this:
$customtax = $customtaxarray;
to this:
$customtax = array_map('intval',$customtaxarray);
and suddenly wp_set_object_terms
now works. That does not explain why wp_set_post_terms
was working instead (unless perhaps it does this conversion automatically?), but at least this is now working as expected.
Related Posts:
- Passing a hardcoded page/post ID into `get_post`
- MySQL Query to Retrieve Category from wp_posts
- Exclude posts that only have the ‘Uncategorized’ category [duplicate]
- How are terms connected with posts in database?
- Importing data from spreadsheet into wordpress DB, along with custom taxonomies and their terms
- get_terms parent for current product only
- deleting terms programmatically
- Adding Multiple Values to a Post Meta Key
- Avoid duplicate post from same Taxonomy
- Set terms in a custom post
- Get posts of ONE taxonomy term of custom post type
- Setting posts_per_page for taxonomy term template
- How to display posts via custom taxonomy terms using checkboxes?
- sql select for post_title and a term name
- Loop parent terms {display posts} AND loop child terms {display posts}
- Check if current user has a post and that post has any term/s from a specific custom taxonomy outside the loop
- Parent category / child category posts
- Only allow posts with a specific term to only be viewed by other authors with the same term in their post
- Count the number of a post types associated with another post type
- Get current post’s nav menu name (term name)
- Accessing Post ID Within Loop
- Loop through taxonomies and loop through their terms (Newbie question)
- How can we print out total number of posts filtered by post type and category?
- Loop through posts by each term and exclude duplicate posts assigned to several terms
- Displaying Results From Custom Taxonomy Query
- How to get all the terms of a post
- How to detect if an ACF custom-field is really in use?
- Changing the post date and time with function
- Why declare $post globally?
- Modify ‘Read more’ link adding a new class
- Modifying admin sidebar contents to show pending posts indicator
- Get post only from ‘standard’ post format
- Add “Post Options” for new wordpress post
- Are all ID’s used unique?
- How to lock content?
- Getting an alphabetic post list with two letters onclick on letter
- How do I change the gallery that is inserted in the post?
- Get the author of the latest revision
- Show posts in category x and y from the 6th most recent post onwards
- Posts Page Featured Image [closed]
- Use template of parent category for single post sub-categories
- loop not displaying posts on custom template page
- get post id in while loops outputting page id
- Adding variable for post title so post template can include auto-generated link to view on external website.com/{post title}
- WordPress 4.4 release produce blank white images when sharing a post on Facebook etc
- Two posts are loaded instead of one?
- When I re-save a post with [code] sections, the entities are double-escaped (> becomes > etc)
- How can I write comments/hidden text in a post?
- Random post category URL
- Getting category posts from a certain year
- custom post scheduler for drafts
- Ajaxify This Code
- How do I display some posts fully on the homepage, and some as an excerpt only?
- How to bulk add vast amounts of posts
- 301 (static page instead latest posts)
- Transferring WordPress Database – Serialised data
- Users problem (multi-author plus multisite)
- Filter only the text in the_content
- Saving custom fields to a custom taxonomy
- Show posts count for Categories and Tags in wp_nav_menu
- How to get subcategories from category slug?
- What are the benefits of setting a “featured image” for a WP blog post?
- How do I insert a after every 5 posts in a WordPress Loop that infinitely loads posts?
- Using system date format
- Auto update post title and slug when post status is changed
- Retrieving posts by their date and category
- wp-link-pages in header and footer of the post
- Post titles and thumbnails as links to custom post types?
- get last post’s link with SQL query
- Output Buffer Issue with Single Post View
- show div only if have a related post inside
- Actions to use when flushing cache (when posts are added / deleted / modified)
- How do I apply a template to my single posts?
- Help Combine These Two PHP Codes
- can’t modify post title using the_posts filter
- How Do I Redirect WordPress Pages but not posts?
- Author post count in category
- Post count doesn’t match number of posts shown in list in admin
- Show post count in custom taxonomy page
- Reusing old post IDs
- Change post value in WordPress
- Display title of all custom posts from same taxonomy term on a custom post template
- Unable to get all the Posts Attachments
- view a list of 3 future post, from the nearest to the most far
- Automatic Table of contents with categories and posts
- Why do some post, listed under the “Mine” Tab, and the same posts listed tunder “Published” Tab
- Rewrite Rule to Combine Taxonomy and Post Type
- Printable Page with all Posts from Tag
- Why the blog posts is not showing?
- Need help with hiding an image within a post in a category
- Delete 100+ posts or media files from wordpress faster than default?
- How to get the postID inside ‘content_save_pre’? Other hook?
- How to filter out post from a category not its subcategory in wordpress dashboard
- Hide Certain Tags on Single Post Page
- How can I change the look of a post as is displayed
- Loop not allowing infinite scroll after post per page limit
- the_time() cannot be placed correctly
- Is there a maximum amount of pages for a multi-page post?
- excerpt in template for specific page
- How can I use wp_after_insert_post with $current_screen?