Add ACF fields to taxonomy by submitting post

39 Views Asked by At

Lets say i have products based on woocommerce, and I want some specific functionality. For example: inside product I created two ACF input fields:

Manufacter Model

Then i have taxonomy named - "klb_make" There must add Manufacter and Model values: Manufactur -> parent, Model -> child

Parent(some manufacter) Child (some model) Parent2(some manufacter2) Child2(some modal2)

and so on..

i have tryed some code

$get_posts = new WP_Query;
add_action( 'init', function() {
$post_id = $get_posts; 
$field_id = 'klb_make_type';
$value = 'My custom value';
rwmb_set_meta( $post_id, $field_id, $value );
}, 99 );`

or:

add_action( 'init', function() {
$post_id = $get_posts;
$field_id = 'klb_make_type';
$value = [
    [
        'parent' => 'Manufacter',
        'child' => 'model',
      
    ],
    [
        'parent' => 'Manufacter2',
        'child' => 'model2',
       
    ],
];
rwmb_set_meta( $post_id, $field_id, $value );
}, 99 );`

But didin't worked

0

There are 0 best solutions below