0

How can I upload .mobi and .epub files in the "Media" section of my WordPress site. I want my customers to be able to download my ebooks in the .epub and .mobi version also, not just in .pdf.

I know there is an HTML code to write in the editor. Do you know what is this and exactly, in which section of the editor must go?

0

1 Answer 1

2

Sounds like you need something like:

add_filter('upload_mimes', function ( $mimes = array() )
{ 
    $mimes['mobi'] = 'application/x-mobipocket-ebook';
    $mimes['epub'] = 'application/epub+zip';
    return $mimes;
} );

to support the uploads, but you might have to adjust the mime types to your needs.

2
  • It seems that OP is asking not only what code to use, but also where to put this. I have a similar doubt. If I put it into theme, this will work only for that single page of my blog network, which uses this theme. And this will be overwritten by next theme update. If I'd like to make this "update-save" and "network-wide", I'd probably have to put this into some separate plugin. Do you have some suggestion? Can you extend this answer to cover where part from OP's question?
    – trejder
    May 9, 2021 at 19:53
  • Thanks for suggestions, haven't looked into this for a long time. Try functions.php file of the current theme, or better create a new plugin file for this and activate. There are also mu-plugins directory for must-use plugins (no activation needed) that you could look into (see e.g. wordpress.org/support/article/must-use-plugins).
    – birgire
    May 9, 2021 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.