最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

theme development - Where is the correct place(s) in twentysixteen's header.php to add a Google webfont?

programmeradmin1浏览0评论

I have a slightly tweaked child theme to twentysixteen (used solely on - feel free to view source!), and I would like to add a Google webfont. / suggests (as one option) to put e.g. <link href="+One" rel="stylesheet"> before your theme imports its stylesheet. That sounds like sensible enough advice, but twentysixteen's header.php does not contain strings I could find like "css". As a result, I don't know where the last line is in header.php before the theme's stylesheet is loaded, or whether (in a child theme to twentysixteen) I should be editing some other file (and if so, which?).

I have provisionally placed <link href="+One" rel="stylesheet" /> in header.php just after the open HEAD tag, but I suspect there are better or more surgical placements.

Where, in a twentysixteen child, should I place an HTML tag to import a Google font or the like?

Thanks,

I have a slightly tweaked child theme to twentysixteen (used solely on https://CJSHayward - feel free to view source!), and I would like to add a Google webfont. http://www.wpbeginner/wp-themes/how-add-google-web-fonts-wordpress-themes/ suggests (as one option) to put e.g. <link href="https://fonts.googleapis/css?family=Sigmar+One" rel="stylesheet"> before your theme imports its stylesheet. That sounds like sensible enough advice, but twentysixteen's header.php does not contain strings I could find like "css". As a result, I don't know where the last line is in header.php before the theme's stylesheet is loaded, or whether (in a child theme to twentysixteen) I should be editing some other file (and if so, which?).

I have provisionally placed <link href="https://fonts.googleapis/css?family=Sigmar+One" rel="stylesheet" /> in header.php just after the open HEAD tag, but I suspect there are better or more surgical placements.

Where, in a twentysixteen child, should I place an HTML tag to import a Google font or the like?

Thanks,

Share Improve this question edited May 11, 2019 at 0:06 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Sep 12, 2016 at 22:07 Christos HaywardChristos Hayward 639 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

You can place it in header.php between starting <head> and closing </head> tags and it should work properly.

Or perhaps a better solution would be to enqueue the style in functions.php

function google_fonts() {
$query_args = array(
    'family' => 'Sigmar+One'
);
wp_register_style( 'google_fonts', add_query_arg( $query_args, "//fonts.googleapis/css" ), array(), null );
        }

add_action('wp_enqueue_scripts', 'google_fonts');
发布评论

评论列表(0)

  1. 暂无评论