Extending the post editor to attach custom files with the media uploader
WordPress offers a very complete media upload tool to easily attach featured images to posts or pages. With a few simple function calls, plugin developers can create an instance of the WordPress media uploader in their custom interfaces, allowing users to easily upload and assign images.
Getting ready
You should have access to a WordPress development environment, either on your local computer or a remote server, where you will be able to load your new plugin files.
How to do it...
Follow these steps to learn how to leverage the WordPress media uploader to allow users to attach files to posts or pages and display them when these items are viewed:
- Navigate to the WordPress
plugins
directory of your development installation. - Create a new directory called
ch5-custom-file-attachment
. - Navigate to this directory and create a new text file called
ch5-custom-file-attachment.php
. - Open the...