Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

wordpress programmatically set acf taxonomy term

$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 by support.advancedcustomfields.com #
 
PREVIOUS NEXT
Tagged: #wordpress #programmatically #set #acf #taxonomy #term
ADD COMMENT
Topic
Name
7+4 =