Learn in this tutorial how to get WordPress to support MOBI files with a simple code snippet.
The MOBI format is quite popular for eBooks and offers some advantages over PDF.
This makes it the perfect candidate if you’re going to sell (or give away) an e-book or e-document.
But have you ever tried to upload a MOBI file to WordPress?
Chances are you’ve encountered a message similar to this one:
There was an error uploading “your_book.mobi”.
Sorry, this file type is not allowed for security reasons.
And WordPress is very zealous about security (which is appreciated, much appreciated). 😉
But sometimes this becomes an inconvenience, especially when you have created the file yourself and you know that it is completely trustworthy.
So today you’re going to discover how to allow MOBI file uploading in WordPress with a simple code snippet
Snippet for WordPress to accept MOBI files
Add the following snippet to the end of functions.php:
It’s that simple. Now you will have no problem uploading your book in MOBI format to the WordPress library.
If you are one of those who take security quite seriously (like me):
WHEN YOU’RE DONE UPLOADING THE FILE, DELETE THE CODE.
This will prevent other users from uploading MOBIs of unknown origin.
As you can see, with a few lines of code you can upload your book in MOBI format to the WordPress library.
If you have any question, please leave it in the comments. And if you want to give me a suggestion for future snippets, please send it through the contact form.
Benefits of being a subscriber. 🙂