Archive | 10:32 am

Use Google Fonts in WordPress

9 Oct

To record in case I forget again:

For example, in google font they provide, general;@import;java

1.Use java for wordpress

Like this code:

WebFontConfig = {
google: { families: [ ‘Dosis:400,700,200:latin’, ‘Exo:800:latin’, ‘Lato:700,900:latin’, ‘Raleway:100:latin’ ] }
};
(function() {
var wf = document.createElement(‘script’);
wf.src = (‘https:’ == document.location.protocol ? ‘https’ : ‘http’) +
‘://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js’;
wf.type = ‘text/javascript’;
wf.async = ‘true’;
var s = document.getElementsByTagName(‘script’)[0];
s.parentNode.insertBefore(wf, s);
})();

Paste that in the header.php. According to my experience, in some template, not the ‘header.php’ but the Header (templates/header.php), but, in most condition shall be in ‘header.php’.
I paste it after the

before the

P.s the icon of the site is also be pasted here in the header.php.


2.
write a div in css like #thefontname {font family: ;}

and then in html file, use div name in the paragraph you want the special font:

Design a site like this with WordPress.com
Get started