Google Font API Thesis and WordPress

By Dan Nedelko

July 30, 2010

Last Updated on December 14, 2022 by Dan Nedelko

So if you keep up on these things you’ll no doubt have heard that Google has released a pretty super nifty and cool new fonts directory which will effectively allow you use some very snazzy fonts  in a very web safe way.

This makes me pretty happy since it’s always a pain to have to ignore high quality fontography in place of web safe fonts. Here’s a bit of background on the whole thing if you’ve missed it.

Google Blog Font Directory Post

Google Font Directory

Google Font Directory Preview Tool

I’m going to quickly cover how I integrated this into a WordPress theme which took all of about 5 minutes then how I integrated it into the ever popular Thesis Theme which I use on quite a number of sites which I own.

Before we dive in here are a few examples. First a non-Thesis example.





Non-Thesis WordPress Integration

  1. Go to The Google Font Directory Preview tool.
  2. Select your font and options.
  3. Go to your website.
  4. Crack open your header.php file.
  5. Add the following link (with the font details you’ve selected) into your file:
  6. [code]<link href="//,italic,bold,bolditalic" rel="stylesheet" type="text/css" >[/code]
  7. Open up your style.css file in your WordPress theme.
  8. Depending on which CSS element you are looking to replace simply comment our your current font styling.
  9. Copy Paste and replace with the Google font preview tool.

For Example:

[code] body {
margin-top: 0px;
padding: 0;
color: #4c4c4c;
background-color: #F3ECC4;
font-family: ‘Cantarell’, serif;
font-size: 14px;
font-style: normal;
text-shadow: none;
text-decoration: none;
letter-spacing: 0.0em;
word-spacing: 0.25em;
line-height: 1.23em;
background-image: url(images/bg.jpg);
background-repeat: repeat-x;

Voila – easy as pie. You can see from the two screenshots below the difference this makes on your site. Much cleaner, more readable, and definitely more professional.

Now what about Thesis? Things are a little bit different there. So let’s dive right in – by the way, I’m not getting into the specifics of changing a CSS element in WordPress because well, this isn’t a WordPress tutorial site. I’m putting this up to be helpful.

If you’re having trouble figuring out how to change your theme CSS elements there are tons of WordPress tutorials out there that can help you out.

Thesis and Google Font Library Integration

Here’s the before of The Dusan Nedelko Foundation which is running Thesis:

Dusan Nedelko Foundation Running Thesis

And After (Ohhh, Ahhh, Ohhhh):

Dusans Website with Thesis and Google Fonts

In a similar way to a normal WordPress theme this is pretty straight forward we just want to play nice with the way Thesis handles things.

Step 1 – Add the include into the section of the theme. I’m sure there are tons of ways to do this. I actually add head elements in a slightly different way than through the Document Head section in the Thesis admin.

Open up you custom_functions.php file and add the following:

[code] // Add the include for the Google Font API’s
function google_font_api() {
$goog = "<link href=\"//\" rel=\"stylesheet\" type=\"text/css\" >\n";
$goog2 = "<link href=\"//\" rel=\"stylesheet\" type=\"text/css\" >\n";
$goog3 = "<link href=\"//\" rel=\"stylesheet\" type=\"text/css\" >\n";
echo $goog;
echo $goog2;
echo $goog3;
// Add the hook

Obviously you need to add the include for whichever Google font you want to add. You can also feel free to copy and paste the lines from the Google Font Directory Preview tool into the Thesis Site Options->Additional Scripts section.

Same deal I just prefer to keep things tidy in my own way.

Step 2 – Add the code to your custom.css to override whichever elements you want:

To change the site title:

[code] .custom #header {
font-family:’Reenie Beanie’, serif;
font-size: 22px;
font-style: normal;
font-weight: 400;
text-shadow: none;
text-decoration: none;
text-transform: none;
letter-spacing: 0.015em;
word-spacing: -0.041em;
line-height: 1.23em;
text-shadow: 4px 4px 4px #aaa;
padding-top: 0em;
padding-bottom: 0em;

To change the body text:

[code] body.custom {
font-family:’Crimson Text’, serif;
font-size: 12px;
font-style: normal;
font-weight: 400;
letter-spacing: 0.015em;
word-spacing: -0.041em;
line-height: 1.23em;

To change the sidebar headline text (this has my own custom styling in there and you can also add/remove whatever you want for style purposes):

[code] /* Custom Widget Headers */
.custom .sidebar h3{
font-family: ‘Reenie Beanie’, serif;
font-size: 24px;
font-style: bold;
font-weight: 400;
text-shadow: 4px 4px 4px #bbb;
text-decoration: none;
text-transform: none;
letter-spacing: 0.015em;
word-spacing: -0.041em;
line-height: 1.23em;
border-top:1px solid #e48902;
border-bottom:1px solid #e48902;

There you have it – as you can see below on my brother’s memorial foundation website: The Dusan Nedelko Foundation the changes make a really nice addition to the site, increasing the styling while remaining nice and simple.

Hope that was helpful and let me know if you have any thoughts, comments, rants, raves or whatever.

Pura Vida.

Dan Nedelko

About Dan Nedelko

A human being spinning around on this big blue marble with the rest of you, interested in Digital Marketing // Music // Art // Family // Business // Founder of

  • Hi,

    Unfortunately, your code is full of HTML tags and won’t parse. You need to remover those and just present a flat text file or everyone that tries to use it will have the same problem.


    • Terence,

      The syntax highlighter copies and pastes just fine for me (and many others). If you highlight the code in the boxes and paste them into TextMate, BBEdit and any other text editor. Hope that helps.

      – Dan

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

    Want a FREE Membership to Marketer Knows?