douwen5951 2019-05-06 12:42
浏览 60
已采纳

WordPress开发 - “编辑风格”问题

I'm creating WordPress theme. But i faced with a interesting problem. So , I added a google font to Editor style. And It works correctly on localhost. Bu doesn't work on real host. Where can be problem ? My Codes :

  # Editor Style support #
  add_theme_support( 'editor-styles' );
  # editor assets #
  add_editor_style(get_template_directory_uri() .'/style-editor.css');
  add_editor_style('https://fonts.googleapis.com/css?family=Poppins:400,500,700');
  add_editor_style('assets/css/font-awesome-4.css');
  • 写回答

1条回答 默认 最新

  • douyan7916 2019-05-06 13:00
    关注

    UPDATED: Give this a try from the Wordpress Developer Documentation: https://developer.wordpress.org/reference/functions/add_editor_style/

    Using Google Fonts

    Google Fonts API provides a single URL for a CSS file that can include multiple variants of a type face, separated by commas. Commas in a URL need to be encoded before the string can be passed to add_editor_style.

    /**
     * Registers an editor stylesheet for the current theme.
     */
    function wpdocs_theme_add_editor_styles() {
        $font_url = str_replace( ',', '%2C', '//fonts.googleapis.com/css?family=Lato:300,400,700' );
        add_editor_style( $font_url );
    }
    add_action( 'after_setup_theme', 'wpdocs_theme_add_editor_styles' );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员