wp_insert_post
-
am I using the wp_insert_post() function to create posts within a loop.
The code works correctly, however, it duplicates the inserts.my code is in following:
`$product = wc_get_product($product_id);
$variation_post = array(
‘post_title’ => ‘Variation #’ . $product_id,
‘post_name’ => ‘product-‘. $product_id .’-variation’,
‘post_status’ => ‘publish’,
‘post_parent’ => $product_id,
‘post_type’ => ‘product_variation’,
‘guid’ => home_url() . ‘/?product_variation=product-‘ . $product_id . ‘-variation’
);$variation_id = wp_insert_post( $variation_post );
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘wp_insert_post’ is closed to new replies.