首页 文章

在WordPress中指定TinyMCE编辑器字体颜色?

提问于
浏览
0

我在WordPress中使用TinyMCE,当你在编辑器中输入时,文本的颜色是#333333或rgb(51,51,51) . 奇怪的是,“选择文本颜色”按钮中的默认颜色是#eeeeee,但是当您在页面加载时键入时,它仍然是#333333 . 我在functions.php中使用此函数来设置颜色:

function change_mce_options( $init ) {
    $init['theme_advanced_default_foreground_color'] = '#eeeeee';
    $init['theme_advanced_text_colors'] = 'eeeeee,ff4343,8383cc';
return $init; }
add_filter('tiny_mce_before_init', 'change_mce_options');

如何更改输入编辑器的文本的默认字体颜色和字体系列?

1 回答

  • 1

    在主题根文件夹中创建 my-editor-style.css 样式表并将样式放在那里:

    body#tinymce.wp-editor { 
        font-family: Arial, Helvetica, sans-serif; 
    }
    
    body#tinymce.wp-editor a {
        color: #4CA6CF;
    }
    

    最后通过在 functions.php 文件中添加以下钩子来加载此文件:

    add_action( 'init', 'wpse8170_add_editor_styles' );
    function wpse8170_add_editor_styles() {
        add_editor_style( 'my-editor-style.css' );
    }
    

    在codex中阅读有关editor styles的更多信息 .

相关问题