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 用三极管设计—个共射极放大电路
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示