You can use wp_set_object_terms fx
From Codex:
This function relates an object (post, link etc) to a term and taxonomy
type (tag, category, etc). Creates the term and taxonomy relationship
if it doesn’t already exist.
wp_set_object_terms( 'id of product', 'term name', 'product_cat', true );
Related Posts:
- Add image to post from external URL
- How to use wordpress $polylang->model->set_post_language in custom php code?
- Create WordPress posts from JSON array using plugin in admin
- Somehow adding to “Insert Into URL” posts are contradicting each other
- Is it possible to pin a post in second position from top
- wp_insert_post not inserting post from XML
- Creating categories while importing via CSV
- wp_insert_post with data from graph api inside a plugin
- On save_post need to wp_insert_post and save partent post id to child post and child post id to parent post
- Choose default template for a page with code
- Is it possible to get a shortcode generated by a plugin, then, using a function, create a new post using that shortcode?
- How to add featured image on front end form?
- wp_insert_post() post_author and return post_id are not working
- Action hook “wp_insert_post” works but not for last imported post
- wp_insert_post hook not being called with wp_publish_post or wp_insert_post?
- wp_insert_post() get Fatal Error from Plugin
- Is it possible to add permalink when using wp_insert_post?
- Suitable hook when creating, updating and deleting posts programmatically
- Can I leave off plugin textdomain for terms used in core?
- Correct way to serialize the data of options table?
- How to force WordPress to temporarily switch locale (using qTranslate)? [closed]
- Custom admin column disappearing when using Quick Edit [duplicate]
- Create page when plugin is activated
- Qtranslate displays empty categories with get_categories()
- How can I translate the name of my Plugin for other languages?
- How to make a plugin auto-add item to nav menu
- Logs to check when the plugin was first installed for the first time
- WordPress Custom Application form
- Facebook Like Button On Individual Comments
- Adding a jquery script to plugin contact form 7
- Keep user’s privileges on accessing contents in JSON response
- Displaying admin notice dynamically
- Get total number of comment of the posts written by an author
- Show Heirachy of categories in WP Download Monitor
- How to replace or display the special characters from JSON API plugin [closed]
- Output HTML only on individual post view
- printf – problem to understand code
- Pass info from functions.php to plugin
- add_query_arg not working
- Widget for adding HTML markup to a page
- WordPress filter that hook after each action/filter hook
- When to use action hooks and plugins
- Uncode theme content block header ignoring saved changes/not updating?
- Unique 4 digit number
- External CSS in WordPress Plugin [closed]
- PHP basics help in WP context – remove a class/function?
- User Session and Stored Cookies not get removed
- Plugin dependencies: show notice like theme plugins dependencies
- get 404 when accessing wp-admin/plugin-install.php
- Pre booking doesn’t work with custom bootstrap modul in woocommerce [closed]
- Custom Pages for Woocommerce Product-Category Pages
- Woocommerce Minimum Price for a Composite Product to add in cart
- What is most efficient way to migrate wordpress website?
- Bulk updates to post_content
- WordPress 3.8.3. custom theme – sliders won’t load js/css files
- Plugin Development Form Self Submission
- How To Extend A WordPress Plugin Without Losing Your Changes [duplicate]
- WordPress call_user_func_array() expects parameter 1 to be a valid callback, class
- Why is my custom post type not being activated on plug-in activation?
- Where to find the code used to render a page that has a shortcode and a template defined?
- WordPress User Post Products
- How to find out whether a plugin is used in pages or posts?
- How to generate an all in one WordPress New content, plugin and theme update report on a website? [closed]
- How can I load the css and jquery explicitly for the login screen
- Overriding an Array in a Plugin’s Class/Function from functions.php
- Canvas | Bouncing balls within a container (with gravity and collisions and background-images on the balls)
- preg_replace() No ending delimiter ‘.’ found [closed]
- How can i summerize posts or news automatically in word press site?
- Pull comments from one page/post into another page/post?
- Do WordPress plugins suport multisite site?
- What’s the default setting for including a in a post
- implement custom roles in custom plugin
- Update widget values from ajax function
- implement checkbox or toggle switch in plugin code
- how can export data in excel file custom plugin
- dbDelta not CREATING TABLE
- wp_mail in pluggable.php return path original settings
- woocommerce with external ftp site
- How to put a maximum real-time users limit
- How to exclude a part of a page in search results
- Help finding a plugin – masonry type post grid
- WP_CRON issue with UTC and local time
- Custom admin plugin read CSV
- How to get short description under heading – Visual Composer [closed]
- plugin installing error
- Get custom term link archive with prefix
- Plugin, add opengraph tags after form submit
- How to save information related to post in database?
- Filter html of WordPress editor in visual mode only
- Creating a page that does not show up in the frontend navigation bar
- Second foreach loop breaking (Posts2Posts)
- Removing this filter added by a plugin
- Which filters or actions involve with index page for plugin?
- Infinite Scroll plugin on Ebuy theme
- Pronamic Info Window
- Gutenberg: Dynamic Block – Show saved data in the editor
- Trying to Understand Shortcodes.
- Is there a way to stop the theme and especially plugins listed?
- How do I edit the action URL on a widget form from a plugin?
- Display Any Field fromAdmin Panel in Frontend via Shortcode?