Add programmatically a downloadable file to Woocommerce products
问题 In my solution I want to automate the product creation as much as possible. One time saver is, in my opinion, to auto add the downloadable file to the product. I have created this function: function fcsp_add_downloadable_file($post_id, $post, $update){ $post_thumbnail_id = get_post_thumbnail_id( $post_id ); $url = get_site_url()."/wp-content/uploads/".get_the_date('Y')."/".get_the_date('m')."/".$filename_only = basename( get_attached_file( $post_thumbnail_id ) ); update_post_meta($post_id, '