Dar*_*oid 9 css php wordpress fonts web-development-server
我正在使用 Wordpress 的字体管理器插件。它有一个很好的选项来上传我已保存到计算机上的字体。我只需要以某种方式让 WordPress 接受它,这样我就可以在这里使用它:
但是,我收到错误:Error uploading the file: Sorry, this file type is not permitted for security reasons.
我如何让 WordPress 暂时允许这样做?另外,这个方法真的有效吗?最终目标是让它显示在上图中的下拉列表中,因为我需要更改标题文本的字体。我可以做任何需要的编程工作。
cla*_*ica 10
不幸的是,对我来说, functions.php的代码片段或插件都不起作用。
我不得不暂时将以下代码添加到wp-config.php:
define('ALLOW_UNFILTERED_UPLOADS', true);
Run Code Online (Sandbox Code Playgroud)
当然,我一上传字体就删除了它。
(但是将来我将尝试使用底部两个答案中建议的压缩字体版本)。
您可以通过在 function.php 文件上添加简单的过滤器代码来允许在您的网站上上传 .ttf 字体。
以下是仅适用于 .ttf 字体的代码
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;
}
Run Code Online (Sandbox Code Playgroud)
您可以在函数中添加更多 MIME 类型以允许上传这些文件。
| 归档时间: |
|
| 查看次数: |
38172 次 |
| 最近记录: |