0

How to include external css like google font http://fonts.googleapis.com/css?family=Lato using add_editor_style() ?

when i add add_editor_style('http://fonts.googleapis.com/css?family=Lato');, in source code will show like this :

<link rel="stylesheet" data-mce-href="http://203.223.152.159/~marineac/wp-content/themes/twentyten/http://fonts.googleapis.com/css?family=Lato&amp;ver=342-201106301" href="http://203.223.152.159/~marineac/wp-content/themes/twentyten/http://fonts.googleapis.com/css?family=Lato&amp;ver=342-201106301">

2 Answers 2

1

You should use the mce_css filter. Not tested:

function so_17961871( $mce_css ) {
    if ( ! empty( $mce_css ) )
        $mce_css .= ',';
    $mce_css .= 'http://fonts.googleapis.com/css?family=Lato';

    return $mce_css;
}

add_filter( 'mce_css', 'so_17961871' );
Sign up to request clarification or add additional context in comments.

1 Comment

1

This was patched in changeset 24735 which I believe is part of 3.6 or 3.6.1.

2 Comments

Yes indeed. Note that if you want to use multiple font faces (e.g., $font_url = 'http://fonts.googleapis.com/css?family=Lato:300,400,700'), you need to url encode the commas: Do str_replace( ',', '%2C', $font_url ) before passing to add_editor_style.
Hi could you please look at this question wordpress.stackexchange.com/questions/214858/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.