Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global $woocommerce;
- $my_post = array(
- 'post_title' => 'My post',
- 'post_content' => 'This is my post.',
- 'post_status' => 'publish',
- 'post_author' => 1,
- 'post_type' =>'product'
- );
- // Insert the post into the database
- $product_ID = wp_insert_post( $my_post );
- if ( $product_ID ){
- add_post_meta($product_ID, '_regular_price', 100 );
- add_post_meta($product_ID, '_price', 100 );
- add_post_meta($product_ID, '_stock_status', 'instock' );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement