How do I allow a single Wordpress site to accept my .ttf file upload?

DarthVoid picture DarthVoid · Jan 16, 2017 · Viewed 18.5k times · Source

I'm using the Font Organizer plugin for Wordpress. It has a nice option to upload a font, which I have saved to my computer. I just need to somehow get Wordpress to accept it so I can use it here:

enter image description here

However, I'm getting an error: Error uploading the file: Sorry, this file type is not permitted for security reasons.

How do I let Wordpress temporarily allow this? Also, is this method even going to work out? The end goal is for it to show up on the drop down list in the image above because I need to change the font of the header text. I can do any programming stuff needed.

Answer

Vishal Gupta picture Vishal Gupta · Jun 21, 2017

You can allow uploading the .ttf font on your site, by adding a simple filter code on function.php file.

Below is the code for .ttf font only

    add_filter('upload_mimes', 'add_custom_upload_mimes');
    function add_custom_upload_mimes($existing_mimes) {
        $existing_mimes['ttf'] = 'application/x-font-ttf';
        return $existing_mimes;
   }

You can add more MIME type in the function to allow to upload those file.