Wordpress Programmatically Set Acf Taxonomy Term

[Solved] Wordpress Programmatically Set Acf Taxonomy Term | Php Frameworks Drupal - Code Explorer | yomemimo.com
Question : wordpress programmatically set acf taxonomy term

Answered by : james-sasb3ny2ov4c

$cat_id_1 = 100; // Term association that is actually output as a term_id
$cat_id_2 = 100; // Term association that is actually output as a term_id
$post_arr = array( 'post_title' => "My title", 'post_status' => 'publish', 'post_type' => 'page', 'post_parent' => $parent_id, 'post_name' => "my-slug", 'meta_input' => array( 'acf_name_of_field_1' => array($cat_id_1) /* #id of term */, 'acf_name_of_field_2' => array($cat_id_2) /* #id of term */, )
);
wp_insert_post( $post_arr );

Source : https://support.advancedcustomfields.com/forums/topic/how-can-i-programmatically-set-a-taxonomy-field-in-wp_insert_post/ | Last Update : Tue, 26 Apr 22

Answers related to wordpress programmatically set acf taxonomy term

Code Explorer Popular Question For Php Frameworks Drupal