This will work:
wp_set_object_terms(
'2',
wp_get_object_terms(
'1',
'my_taxonomy',
array("fields"=>"ids")
),
'my_taxonomy'
);
Explanation:
I added this: ,array("fields"=>"ids")
to the attempt i wrote in the question to make the wp_get_object_terms
return array of ids alone (what the wp_set_object_terms
want to get.
Related Posts:
- Get taxonomy terms only of the WP_Query current posts
- Query all posts of a custom taxonomy term
- How to get post’s current parent term ID?
- How to filter custom taxonomy term name, slug, and description?
- Hierarchical taxonomy list with modificated term links
- Exclude product attributes from taxonomy terms loop
- Show all terms of a custom taxonomy?
- How to find objects by terms
- Display certain amount of posts on taxonomy archive page
- Get used terms by an author as array of strings
- How to get the term before the last from a custom taxonomy?
- Get all taxonomies for all post types
- How do I get taxonomy terms by ID in a specific order
- WP_Query use for a filter with multiple Taxonomies and Terms
- Adding Multiple Values to a Post Meta Key
- Display Post co-authored in Author Page
- conditional statement for custom taxonomy
- get_the_terms – only top level
- get_terms orderby numeric
- Rename “Portfolio” slug?
- get_term_link() returns incorrect url
- Create a hierarchical taxonomy list in WordPress
- Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?
- Why my filterable portfolio page work not perfectly between slug button and slug output WORDRPESS?
- Loop through categories and display posts title under each dropdown
- How to get original custom taxonomy slug after the slug has been rewritten?
- Get term siblings of current child taxonomy
- How to show only subcategories in parent category not parent category?
- List taxonomy term slugs within shortcode (do_shortcode)
- Hide image if taxonomy term is empty
- Isotope Drop Down Categories Filter Function
- Show the section only if custom taxonomy was chosen
- How to insert wp_users ->user login name to wp_terms when a new user registering?
- Create a a form for custom taxonomy terms
- WordPress custom taxonomy
- How to break up php code to avoid echo
- PHP displaying wrong custom taxonomy images
- Trying to display terms from custom taxonomy within function
- Woocommerce Custom Meta Boxes- How to only display if they actually have content
- Hi need update in my terms for other taxonomy
- How to change the author box selection on a post to a custom taxonomy
- WordPress: Export/Import Yoast meta title & description to custom taxonomy
- Show related products by attribute based and certain conditions
- Display acf taxonomy attachment
- How to hide a child category and show his parent category
- How do I edit the terms output args or array data?
- update_term_meta() only updating once on certain meta keys
- How to retrieve taxonomy Metabox fields in frontend
- ACF Taxonomy field values not select in backend
- ACF – Can’t get custom post type by taxonomy
- WordPress search query, how to modify the sql
- How to insert text into post based on category – via single.php file
- New term taxonomy and description in front page. Input’s
- Filter By Term Not Working – Custom Post Type
- how to display child terms with parent terms in custom taxonomy?
- How to display terms from two taxonomies in one php code?
- Custom Taxonomy as Link
- Pass custom value to custom taxonomy
- Get all the contents of taxonomy and sort by term
- How to get all the terms of a post
- Query specific posts per user selections from dropdown menus
- ISOTOPE – Missing/Invalid Arguement Get Terms
- WordPress different custom tag being displayed in on tag list
- Three different queries on same page
- WordPress taxonomy and terms question
- Put ACF function output code the_terms
- Get Posts Under Custom Taxonomy
- How to update custom fields using the wp_insert_post() function?
- Inserting terms in an Hierarchical Taxonomy
- Get Posts by Custom Post Type ,Taxonomy, and Term
- Disable Attachment Pages Completely
- Inject post (from specific category) between posts in Loop
- How to Add Custom Fields to Custom Taxonomies in WordPress CLEANLY
- Displaying the category name of a custom post type
- How to limit the number of terms (terms acts like categories)
- Show WordPress Custom Taxonomy Items Based On a Selected Item From Another Custom Taxonomy
- Remove option to allow trackbacks/pingbacks from post page options
- How do I list custom taxonomy terms without the links?
- Exclude specific slug in ‘get_terms’
- Creating custom Woocommerce attribute taxonomies from a plugin
- Exclude posts that only have the ‘Uncategorized’ category [duplicate]
- Is there a way to disable a term rather than deleting it?
- wp_insert_term doesn’t work with custom post type’s taxonomy
- How to paginate a list of custom taxonomy terms?
- wp_set_object_terms and arrays
- Modify Term Update Redirection
- How can I select a primary category?
- How are terms connected with posts in database?
- Return only the custom sub-term for custom post type, do not echo term-parent
- Display posts by month
- Check if current term is a child of another term
- Retrieve single term slug
- Custom SQL query to get List of posts with featured image url
- get_terms() doesn’t return empty terms even though hide_empty is false
- Alter query on edit.php
- Formating the_terms() function output
- Permanently remove first image from posts
- WordPress custom taxonomy description for each post?
- How to get year, month and hour in WordPress?
- Custom Taxonomy Only Showing Top Level Terms in Admin?