save_post requiere at least one uploaded file to be published

I didn’t test this, but it should work: function check_post_attachments($post_id, $post){ if(empty(get_posts(array(‘post_type’ => ‘attachment’, ‘post_parent’ => $post_id)))){ $post[‘post_status’] = ‘draft’; wp_update_post($post); } } add_action(‘save_post’, ‘check_post_attachments’);

How can I set taxonomy programmatically

You should hook your actions to the save_post hook. It fires right after the post is created and the $post_id and other $post data variables are already available. Something like this should do the trick: add_action( ‘save_post’, ‘jason_code_save_post’, 10, 2 ); function jason_code_save_post( $post_ID, $post ) { if ( ‘code’ != $post->post_type || wp_is_post_revision( $post_ID …

Read more