Learn in this tutorial how to get WordPress to support EPUB files by using a simple code snippet.
The EPUB format is very popular for ebooks and offers some advantages over PDF.
This makes it a perfect candidate if you’re going to sell (or give away as lead magnet) a book or electronic document.
But, have you ever tried to upload an EPUB file to WordPress?
Chances are you’ve come across a message similar to this one:
There was an error uploading “your_book.epub”.
Sorry, this type of file is not allowed for security reasons.
WordPress is very jealous of security (which is very much appreciated). 😉
But sometimes this becomes an inconvenience, especially when you have created the file yourself and you know that the EPUB is totally trustworthy.
So today you’re going to discover how to allow the upload of EPUB files into WordPress with a simple snippet of code
Snippet for WordPress to accept EPUB files
Add the following fragment at the end of functions.php:
It’s as simple as that. Now you’ll have no trouble uploading your book in EPUB format to the WordPress library.
If you take security quite seriously (like me):
WHEN YOU’RE DONE UPLOADING THE FILE, DELETE THE CODE.
This prevents other users from uploading EPUBs from unknown sources.
As you can see, with a few lines of code you can upload your book in EPUB format to the WordPress library.
Any questions? Let me know in the comments.
And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉