在 wordpress 中编辑 post 时如何设置指定的字体系列?

How to set the font-family as specified when editing post in wordpress?

我创建了一个子主题,为每个 html 元素设置了我想要的 DejaVu Sans Mono 字体系列。

vim /var/www/html/wp-content/themes/twentyfourteen-child/style.css
*{
    font-family:"DejaVu Sans Mono" !important;
}

我使用 twentyfourteen-child 作为我的 wordpress 主题。
每个处于编辑状态的字符都不是DejaVu Sans Mono.

post中的每个字符在发布后都是DejaVu Sans Mono

如何在编辑 post 时将字体系列设置为 DejaVu Sans Mono

您可以使用浏览器开发人员工具来查看样式表的实际文件。
您只编辑了主题的样式表 - 因此仅适用于您网站的前端!

在我的 wordpress 系统上,我得到了您需要的样式表的 url。它是:

your.site.com/wp-includes/css/editor.min.css

在那里你可能会找到类似

的东西
.wp-editor-area {
    font-family: Consolas,Monaco,monospace;
}

将其更改为

.wp-editor-area {
    font-family:"DejaVu Sans Mono" !important;
}

如果您想更改后端的样式,您还可以查看 /wp-includes/ 和 /wp-admin/ 中的样式表。

请记住,这些更改在任何更新后都会恢复正常。

希望对您有所帮助!

更改编辑器样式的简单解决方案。在 functions.php 中添加:

function myFunc123( $settings ) {
    $settings['content_style'] .= 'body#tinymce {font-family: DejaVu Sans Mono;}'; return $settings;
}
add_filter( 'tiny_mce_before_init', 'myFunc123' );