<?php /** * Template name: Create Product * @package storefront */ $post_id = wp_insert_post( array( 'post_title' => 'Adams Product', 'post_content' => 'Here is content of the post, so this is our great new products description', 'post_status' => 'publish', 'post_type' => "product", ) ); wp_set_object_terms( $post_id, 'simple', 'product_type' ); update_post_meta( $post_id, '_visibility', 'visible' ); update_post_meta( $post_id, '_stock_status',...
Originally asked by Ravi Shankar on Stack Exchange (stackoverflow) (CC BY-SA 3.0).