Automatically Create a post when uploading audio files
-
I’m looking for a way to upload audio files to the media library and create a post automatically. Ideally when a user loads a audio file into the Media Library
- Go to Media library > upload media
- WordPress checks to see if its a audio file.
- If so create a post that contains the link to the audio file in the content of the post.
I found this snippet of code that actually allows you to create posts when uploading images and attaches them them as a featured image. I figure the principle much the the same.
add_action('add_attachment', 'create_post'); function create_post( $attach_ID ) { $attachment = get_post( $attach_ID ); $my_post_data = array( 'post_title' => $attachment->post_title, 'post_type' => 'posts', 'post_category' => array('audio-library'), 'post_status' => 'publish', 'post_content' => '<a href="Need Link Here">Click to Play</a>' ); $post_id = wp_insert_post( $my_post_data ); add_post_meta( $post_id, '_thumbnail_id', $attach_ID, true ); return $attach_ID; }
I’m not much of a coder and I can’t seem to wrap my head around this. Ideally what I’m looking to do is turn wordpress into a audio library itself and allow back end users to upload audio files and have them display on the front-end as a post but without having to upload each audio file and create each post one by one. I got like 200 to start with (>.<)
I figure wordpress has all the functionality already there I just need to get it working together. Even a plugin that can manage audio files in such a way would be wonderful but I have yet to find one.
Thoughts?
P.S. I working with WordPress 3.1.4 darn server only got PHP 4, working on getting that upgraded (pain in the butt).
- The topic ‘Automatically Create a post when uploading audio files’ is closed to new replies.