-1

I added the following code to functions.php to install Roboto Google Font for my WordPress website. For some reason it appears to be italic and not normal font-style when I edit the CSS property.

function google_fonts() {
    $query_args = array(
        'family' => 'Roboto:300'
    );
    wp_register_style( 'google_fonts', add_query_arg( $query_args, "https://fonts.googleapis.com/css" ), array(), null );
}

add_action('wp_enqueue_scripts', 'google_fonts');
  • 2
    if the font is loaded, it is a css issue not a wordpress one, and therefor off-topic here – Mark Kaplun Aug 17 '17 at 6:44
1

What you are experience is probably issue with something else. If you try and access this link:

https://fonts.googleapis.com/css?family=Roboto:300

Directly, you can see that all the font families have a normal style. You might have another CSS rule overriding them. Check for that, and also refresh your browser's cache.

The second note is, you are only registering the styles. You have to also enqueue them using wp_enqueue_style. So your code should be like this:

function google_fonts() {
    $query_args = array(
        'family' => 'Roboto:300'
    );
    wp_register_style( 'google_fonts', add_query_arg( $query_args, "https://fonts.googleapis.com/css" ), array(), null );
    wp_enqueue_style('google_fonts');
}

add_action('wp_enqueue_scripts', 'google_fonts');

Right now I'm guessing you are using some other enqueued google font.

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