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' );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?