Using WordPress Media Uploader in a Plugin or Theme: This One WORKS!

WordPress already has a nice media uploader built in so there is no reason to built another one into your theme or plugin. Pulling it into your project is also super simple, if you know how to do it that is. Finding this illusive code is not as simple as you would think though, as you probably know by now too.

Hours and hours of searching for a piece of code that will work in a sea of results that are either outdated or simply do not work, finally I found some code that did half the job and then after searching some more and almost giving up, I found the last piece that made this uploader script complete and work flawlessly. This one will even work with multiple upload fields on a page.

The first thing you want to do is add the actions to the top of your script that will pull in the necessary javascript and styles for the media uploader.

Then you write your page and once you get to the place where you need the upload field, add this code:


That is it, so simple. I’ve wanted to utilize this feature for so long but have not had a chance to until just recently. I will also be using it in a new awesome related posts plugin I am working on that will be available for all soon. It will blow all the other ones out of the water, so keep an eye out for it.

If this becomes stale like other uploader scripts out there, and I have not updated it yet, please let me know and I will update it.

Share this with your friends!
Share on Facebook
Tweet about this on Twitter
Pin on Pinterest
Share on LinkedIn

No Comments

No comments yet.

Sorry, the comment form is closed at this time.