Adding file upload to page and post in WordPress without a plugin

April 29, 2012

This article is to help some people having trouble adding this function into WordPress.

This is a modified version of this Steve Taylor‘s work.

Include this in a function.php file and it will add custom fields to post and page.

By default it will only display 1 field.
This field allow you to use the media library to insert the url of the image or file you selected.

Select your image and click “Insert into post” button just has you would add a image to the content.

You can add multiple fields if you want.
You only have to change this to add more fields:

Hope it helps