【问题标题】:Wordpress Custom Style EditorWordpress 自定义样式编辑器
【发布时间】:2019-07-16 08:49:46
【问题描述】:

我想在 Wordpress 上自定义我的所见即所得编辑器。

目前,我已将以下代码添加到我的 functions.php 文件中,它正在 Wordpress 后台运行。

function custom_editor_styles() {
    add_editor_style('editor-styles.css');
}

add_action('init', 'custom_editor_styles');

我可以在后台看到我的自定义 CSS,但它在前台不起作用。

谁有显示自定义 css 的解决方案?

谢谢

【问题讨论】:

    标签: css wordpress styles editor


    【解决方案1】:
    add_action( 'wp_enqueue_scripts', 'my_custom_css' );
    
    function my_custom_css() {
    
        if(!is_admin())
        wp_enqueue_style( 'my-custom-css', get_stylesheet_directory_uri() . DIRECTORY_SEPARATOR . 'editor-styles.css', [], null,'all' );
    }
    

    试试这个代码sn-p

    【讨论】:

    • @WDCreativ 更新了答案
    【解决方案2】:

    我找到了解决办法。

    其实我并不知道style-editor.css文件只是用来在后台看预览的。

    我在想 style-editor.css 也用于自定义前面的 css。但其实还是需要把主css文件中的代码复制过去。

    所以,我的第一个代码版本正在运行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-09-10
      • 2018-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-03
      • 1970-01-01
      相关资源
      最近更新 更多