0

I have a code that I need to insert into the HTTP header of my website to make Google Fonts work again.

My Google Fonts aren't rendering on one of my simple websites (http://ceobusinessalliance.com). I coded it from scratch using Bootstrap and WordPress. They were rendering before but are no longer. According to the error in the console and Google's support page (https://developers.google.com/fonts/docs/troubleshooting), I need to make sure Access-Control-Allow-Origin:* is in the header.

What is the function I use to do this? I'm not a very strong WordPress developer. I mostly work with developing themes.

Edit: I am using Chrome.

4
  • I don't see any errors in the dev console, and the font files are loaded properly for me, although as you said, they aren't showing up on the site. Did anything else change? Did you upgrade anything? Commented Nov 25, 2014 at 18:37
  • I haven't upgraded anything lately. Usually, I update once a month and check to make sure everything is working. I suspect it might be something with Google? Or an update with my browser (Chrome)?
    – Tara
    Commented Nov 25, 2014 at 19:11
  • Your page renders fine for me in Chrome (Roboto Slab and PT Sans fonts), not getting console error either.
    – Rarst
    Commented Nov 25, 2014 at 19:56
  • You're right. It's showing up for me, too. Everywhere but the h3 tags on the homepage! Please see the screenshot here: i61.tinypic.com/2mdjdxz.png . I know this is beyond help about WordPress, but I really appreciate your guyses help on this.
    – Tara
    Commented Nov 25, 2014 at 20:01

1 Answer 1

1

Wordpress has the action send_headers, which you can use to make it send additional headers:

add_action( 'send_headers', 'add_header_acao' );
function add_header_acao() {
    header( 'Access-Control-Allow-Origin: *' );
}

See the documentation http://codex.wordpress.org/Plugin_API/Action_Reference/send_headers

6
  • Thanks, JHoffmann. It doesn't seem to have solved my Google Fonts issue. Is there any way I can test to see if the browser read the command? (I looked through inspect element and couldn't find anything).
    – Tara
    Commented Nov 25, 2014 at 19:00
  • First off: For me the fonts are rendering (in FireFox), at least for example the nav menu is in Roboto Slab as it should be.
    – JHoffmann
    Commented Nov 25, 2014 at 19:12
  • For me as well. Body is PT Sans. Commented Nov 25, 2014 at 19:12
  • You can see if the header arrived at the client if you use tools like the network monitor in FireFox. And there too I can see the header on your site.
    – JHoffmann
    Commented Nov 25, 2014 at 19:13
  • Yes, I too can see it in Firefox. The issue is in Chrome. I neglected to add that to the question. I will add that information now.
    – Tara
    Commented Nov 25, 2014 at 19:38

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.