I have this code straight out of one of default themes to load two Google fonts, except I changed the function name. The fonts are not loading, sans serif font shows instead. How do I troubleshoot this?

//add Google fonts

add_action( 'wp_enqueue_scripts', 'sg_add_google_fonts' );

function sg_add_google_fonts() {

 $query_args = array(
   'family' => 'Dosis:400,600,700|Roboto:400,400italic,700,700italic'

   add_query_arg( $query_args, '//fonts.googleapis.com/css' ), 
 wp_enqueue_style( 'google-fonts' );


in style.css

h1, h2, h3, h4, h5, h6 {
    font-family: 'Dosis', sans-serif;
    font-size: 32px;
    color: #3c3c3c;

body {
    font-family: 'Roboto', sans-serif;
    font-size: 24px;
    color: #3c3c3c;

I actually never was able to enqueue anything in WP - scripts, style sheets, nothing, and ended up hardcoding URLs in the header. I would like to find out a general method how to find out what's not working while using enqueue. Is there some kind of an error message I can have output?

Thank you!

  • What theme are you using? Does it call wp_head() within the head tag? Have you looked at the page source to verify if the style and script tags are there or not?
    – Milo
    Commented May 22, 2017 at 2:03
  • it's a custom theme, yes, the problem was with wp_head. I now understand that wp_enqueue_scripts prints out script tags! :). If you put this as an answer I will accept it. :)
    – Natalia
    Commented May 22, 2017 at 2:28

1 Answer 1


It works for me. Please try it out.Thanks

    function tf_add_google_fonts() {wp_enqueue_style( 'tf-google-fonts', 'http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,700italic,400,700,300', false ); 

add_action( 'wp_enqueue_scripts', 'tf_add_google_fonts' );

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.