How to Add Additional File Types to be Uploaded in WordPress
Check Out More At: WP Beginner
WordPress: Best WordPress Plugins | WordPress Tutorials
How to Add Additional File Types to be Uploaded in WordPress
Product Image | Product Name / Primary Rating / Price | Primary Button / Description |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Elementor is an amazing website builder plugin for WordPress. Elementor makes it easy to create beautiful and high converting websites yourself without having to learn code.
Gravity Forms is a WordPress plugin that creates powerful forms quickly and easily, with drag-and-drop fields, custom notifications and confirmations, and custom styling capability.
Kadence Theme is a powerful, intuitive and flexible WordPress theme that offers an expansive set of features and customization options.
It includes a robust page builder, beautiful design options, mobile-friendly responsiveness, powerful SEO tools and optimized performance for faster loading times.
It's perfect for creating stunning websites without needing to write any code.
Cloudways is a managed cloud hosting platform that simplifies cloud infrastructure deployment and management.
It provides an intuitive dashboard, automated backups and optimized stack for speedy performance. It also provides 24x7 support with multiple server locations, enabling businesses to host their applications quickly and securely.
No matter what type of site you have, you’re likely going to want to allow users to upload files of some kind. Whether it’s photos, PDFs, or Word documents, being able to upload and share files is a useful feature that can come in handy in a number of situations.
Fortunately, adding file upload functionality to WordPress is relatively easy to do. In this article, we’ll show you how to add additional file types to be uploaded in WordPress.
Why You May Need to Add Additional File Types
By default, WordPress allows you to upload the following file types:
Images (jpg, jpeg, png, gif, ico)
Audio (mp3, m4a, ogg, wav, midi)
Video (mp4, m4v, mov, wmv, avi, mpg, ogv, 3gp, 3g2)
Documents (pdf, psd, doc, xls, ppt, odt, ods, odp)
After you install WordPress, these are the only file types that you’ll be able to upload by default. However, in some situations, you may need to upload additional file types that aren’t on this list.
For example, let’s say you run a site that allows users to submit photos. If you want users to be able to submit files in RAW format, you’ll need to add that file type to the list of allowed file types.
In another example, let’s say you have a blog and you want to be able to upload ebook files (in the PDF or ePub format) so that your readers can download them. Again, you’ll need to add these file types to the allowed list.
How to Add Additional File Types in WordPress
Adding additional file types in WordPress is a two-step process. First, you’ll need to add a filter to your site’s functions.php file. This filter will tell WordPress which file types you want to add to the allowed list.
Second, you’ll need to add some code to your .htaccess file. This code will ensure that WordPress recognizes the new file types that you’re allowing.
Let’s take a look at both of these steps in more detail.
Step 1: Add a Filter to functions.php
The first thing you need to do is add a filter to your site’s functions.php file. This filter will tell WordPress which file types you want to add to the allowed file types list.
To do this, you’ll need to connect to your site using an FTP client. Once you’re connected, navigate to the /wp-content/themes/your-theme-name/ folder. In this folder, you should see a file named functions.php.
Download this file to your computer and then open it in a text editor. Once you have the file open, look for the following line of code:
After you find this line, add the following code snippet below it: