Pass ACF custom field value to taxonomy

Viewed 46

I created 2 cron actions (one for sold items, one for unsold) to load posts from API connections. Loaded posts has ACF pro field (radio button type) called "status", each time the cron load posts, it will create

add_post_meta( $post_id, 'status', 'Unsold', true );

or

add_post_meta( $post_id, 'status', 'Sold', true );

So the post's custom field can show this status. My question is, how to automatically assign posts to the "Unsold" or "Sold" category when cron action runs? I tried update_term_meta etc but no luck.

1 Answers

I figured it out.

wp_set_object_terms($post_id, 'custom_post_type_cat_slug', 'custom_post_type_cat', true);
Related