Publish product with image
-
I have this code that when a new vendor is created, it automatically publish a new product on his page.
add_action( 'wcfmmp_new_store_created', function( $member_id, $wcfmmp_settings ) { $product_args = array( 'post_title' => 'Product title', 'post_status' => 'publish', 'post_type' => 'product', 'post_excerpt' => 'Description', 'post_content' => 'Here is the content of the product', 'post_author' => $member_id, 'post_name' => sanitize_title('Product title') ); $new_product_id = wp_insert_post( $product_args, true ); update_post_meta( $new_product_id, '_wcfm_product_author', $member_id ); // Set Product Type wp_set_object_terms( $new_product_id, 'simple', 'product_type' ); // Set Price update_post_meta( $new_product_id, '_regular_price', '0' ); update_post_meta( $new_product_id, '_price', '0' ); }, 50, 2 );The issue is that it doesn’t set an image. Is there a way to add the image of the product?
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
The topic ‘Publish product with image’ is closed to new replies.