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
- How do I list custom taxonomy terms without the links?
- Exclude posts that only have the ‘Uncategorized’ category [duplicate]
- Is it possible to get a Previous/Next Taxonomy term archive URL?
- Display taxonomy term only if there’s a value
- Use template for posts with a particular category grandparent
- “before delete post” action fire when the post is updated?
- display taxonomy slug from term ID
- Sum custom field values of particular taxonomy
- Automatically add custom CSS to new posts using a category template
- Displaying the last post on static homepage
- Get posts of ONE taxonomy term of custom post type
- Displaying custom taxonomy on WooCommerce product page
- working with term_relationships table
- Find Site ID From WP_Post
- one post per term taxonomy
- How can I change the output display of my pagination?
- Reading settings in the home page precisely home.php
- Displaying list of posts in category page
- How can I get “Previous” and “Next” to show in the navigation besides the links?
- how to edit a specific post slug using a php code?
- How to pick “full/thumbnail” images in the loop?
- Saving a post ID to use in a form elsewhere on website
- Use wp_list_categories to list parent categories from actual term
- Pagination at category doesnt work with same name of page
- Retrieve the child terms by having the parent’s information
- How to create a non removable taxonomy term?
- How to pull date/time in french format for wordpress post?
- How to display last whole post on the homepage
- Add wp posts to cutom masonry grid
- How to get all posts related to a taxonomy?
- Why get_terms() behaves strangely when being called in admin (for use in meta box)?
- ‘posts_per_page’ in costum page type
- Custom Post Status & Taxonomies
- List of child pages fetch next results at link click
- Set post to draft if matching word is found in the post