It’s as easy as:
function wpse_199523_save_imdb_terms( $post_id ) {
if ( ! $imdb = get_field( 'imdb_id', $post_id ) )
return;
if ( ! $data = imdb_connector_get_movie( $imdb ) )
return;
if ( ! empty( $data['actors'] ) )
wp_set_object_terms( $post_id, $data['actors'], 'actors' );
if ( ! empty( $data['director'] ) )
wp_set_object_terms( $post_id, $data['director'], 'directors' );
}
add_action( 'wp_insert_post', 'wpse_199523_save_imdb_terms', 500 /* Ensure we run after ACF */ );
Refer to the codex on wp_set_object_terms
Related Posts:
- WP REST API no longer supports filter param, so how do I get posts in a custom taxonomy?
- Displaying the post count of all custom taxonomy terms in a list format
- WordPress REST API – get custom taxonomy category posts
- Extra fields on categories that is available via the WP-API?
- get_term_children for immediate children only (not grandchildren)
- Custom taxonomies capabilities
- Can’t get a custom template taxonomy page to display
- Display category posts grouped by taxonomy
- Is there a way to ‘Lock’ a Taxonomy?
- Can I turn off write-in tags/taxonomies?
- get_query_var(‘paged’) always returns empty
- Return only the custom sub-term for custom post type, do not echo term-parent
- Using tax_query creates a 1 = 0 or 1 = 1 in $wp_query->request
- Displaying the Name of the Queried Taxonomy Term on a Term Archive Page?
- Connect Users and Taxonomies
- How can I set a default listing order on the admin page for a custom taxonomy? (without plugins)
- Post tags saving as both tag name & tag ID on post update when tags are displayed as checkboxes
- Retrieving custom taxonomy in order, but excluding specific tax IDs
- Sort Custom Taxonomy Terms in admin by custom order
- Taxonomy query for children of parents
- Removing the base “Author” or changing it to something else. is it possible?
- how to get title to custom tags page
- Change in custom taxonomy permalink causes 404 error for another custom taxonomy
- Display sub-taxonomies based on SELECTED parent-taxonomy
- Checking if a Page has an Associated Term?
- How to redirect custom post type archive to first term of associated taxonomy?
- Refresh Taxonomies
- Get Bottom Most Level Taxonomy Terms?
- Get custom taxonomy description with paragraph tags
- Get pages only with a specific taxonomy
- Share taxonomy between user and posts?
- Displaying custom taxonomy terms active trail
- How to obtain the link/URL to the feed of a custom taxonomy?
- get_term_children doesn’t return an array of children terms
- List Recent Post Titles from Custom Taxonomies?
- Term count by user
- Get taxonomy parent using child slug (from merged taxonomies)
- add taxonomy as one of menu items
- Creating a custom search form
- One query to get posts and their taxonomy terms
- Conditional display for custom fields/taxonomy
- How do I keep the page I’m on within the URL when running a search on a taxonomy?
- Query posts by taxonomy with current term
- problem in taxonomy-{taxonomy}.php pagination
- wordpress testimonials
- 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
- Retrieving only custom post types with two required terms (from diferente custom taxonomies each)?
- Best structure for entering recipes in a WordPress theme?
- Get posts by Taxonomy without terms
- Is this the proper way to get a taxonomy description into a post template?
- Admin (All posts) stop responding problem
- Why get_page_template() doesn’t show taxonomy template file name?
- Website loading slowly – Advanced Custom Fields images
- custom post type, hide or disable the status line in publish meta box
- Removing custom taxonomies from the admin menu
- Custom post type Category Display
- How to get attached image to taxonomy..?
- delete term from taxonomy and assign in new one
- How to create a custom template for custom taxonomy wp-tag-cloud?
- Find terms in a custom taxonomy based on the hirearchy
- Need to display custom taxonomy on single page – not working
- WooCommerce custom taxonomy as meta?
- Query custom taxonomy for category including children
- SQL / wp_update_post: change post custom field to CPT post taxonomy
- Only display latest custom taxonomy post
- Get 1st parent category id from post
- Filter by Custom Taxonomy AND Custom Field
- Custom Permalink Structure for terms/taxonomies of custom post type
- register_taxonomy for both ‘Post’ & ‘Page’
- Display custom taxanomy on woocommere product page
- Show recent posts from a custom taxonomy in wordpress
- update attribute of specific products in woocommerce
- when custom taxonomy is empty, the page won’t load
- How to structure all custom-taxonomy with three verbs(a,b,c) and route them accordingly?
- how do you pull data from two taxonomies?
- problem : Custom taxonomy template not showing
- register_taxonomy_for_object_type (images) : how to use it ?
- Display multiple taxonomies in a function
- Restrict user to terms in a custom taxonomy registered for both posts and users
- WordPress search form and search result through ACF field in custom taxonomy
- Exporting Custom Taxonomy Description without Plugin
- How do I display post count of a custom post type with custom category taxonomy in wp_menu_nav?
- WordPress Main Menu with dynamic url
- wp_insert_post and custom taxonomy
- WordPress tag or archive php file customization
- Dynamic value for get_option linked to taxonomy term_id?
- Best Method to Switch Between Terms (Custom Taxonomy)
- custom taxonomy don’t return a value
- If page is a taxonomy do X, if is a term, do Y
- Getting the parent terms adds additional empty markup [closed]
- How to query authors by custom taxonomy?
- Custom taxonomy list in two columns
- get multiple values from $_GET from multiple checkboxes
- Get post terms with hierarchical relationships
- Using wp_query is it possible to orderby taxonomy?
- Way to organize content – custom taxonomies or other way?
- Using post type archive page for taxonomy archive
- Taxonomy archive link from term id