Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #195621

    Hi Guys – i’m using a child theme of Enfold and I want to call the following stylesheet in my theme

    <link href=’http://fonts.googleapis.com/css?family=PT+Sans|PT+Sans+Narrow:400,700|PT+Sans+Caption’ rel=’stylesheet’ type=’text/css’>

    what is the best way to do this? Is it by the functions.php? If so do I need to add a functions file to my child and make sure it’s empty with only the function calling the google font? Please advise so I don’t break anything and the best practice for your theme.

    Cheers

    #195682

    Hey ShortieD!

    Please add this on functions.php:

    add_filter( 'avf_google_heading_font',  'avia_add_heading_font');
    function avia_add_heading_font($fonts)
    {
    $fonts['PT Sans'] = 'PT Sans:400,700,400italic,700italic';
    return $fonts;
    }
    
    add_filter( 'avf_google_content_font',  'avia_add_content_font');
    function avia_add_content_font($fonts)
    {
    $fonts['PT Sans'] = 'PT Sans:400,700,400italic,700italic';
    return $fonts;
    }

    You’ll be able to select the new font on Enfold > Styling > Heading and Body font.

    Best regards,
    Ismael

    #195930

    Thanks Ismael – do I need to make sure my child theme functions.php is completely empty except for this function?

    #196037

    Hi!

    You can place it at the very bottom of functions.php. :)

    Best regards,
    Ismael

    #196048

    just to be clear, and leave all the other code in the child theme’s funciton.php – which is the same as the parent theme?

    #196535

    Hi!

    Child theme functions.php.

    Regards,
    Josue

    #196539

    Hi Guys – there really does seem to be some confusion – let me be clear.
    Many of the child themes I’ve worked on require the function.php to be completely empty except for the specific child theme function – otherwise it breaks the site.

    My question is whether for the Enfold theme – does the child theme’s functions.php file need to only hold the child functions or does it also include the parent functions?

    Please advise?

    #196546

    Hi!

    You can have both either custom new functions or parent functions, for example if you want to modify an already created function from the parent theme, you just need to copy the whole function with the same name and it will be replaced.

    Cheers!
    Josue

    #197848

    Thanks Guys – wanted to add 2 fonts – so I’ve added this to the child theme functions – but when I select PT sans Narrow for the headings it defaults to PT sans – I’ve had to override in the stylesheet – any clues as to what I might be doing wrong?

    add_filter( ‘avf_google_heading_font’, ‘avia_add_heading_font’);
    function avia_add_heading_font($fonts)
    {
    $fonts[‘PT Sans’] = ‘PT Sans:400,700,400italic,700italic’;
    $fonts[‘PT Sans Narrow’] = ‘PT Sans Narrow:400,700’;
    return $fonts;
    }

    add_filter( ‘avf_google_content_font’, ‘avia_add_content_font’);
    function avia_add_content_font($fonts)
    {

    $fonts[‘PT Sans’] = ‘PT Sans:400,700,400italic,700italic’;
    $fonts[‘PT Sans Narrow’] = ‘PT Sans Narrow:400,700’;
    return $fonts;
    }

    #197911

    Hi!

    Use this instead:

    add_filter( 'avf_google_heading_font', 'avia_add_heading_font');
    function avia_add_heading_font($fonts)
    {
    $fonts['PT Sans Narrow'] = 'PT Sans Narrow:400,700';
    $fonts['PT Sans'] = 'PT Sans:400,700,400italic,700italic';
    return $fonts;
    }
    
    add_filter( 'avf_google_content_font', 'avia_add_content_font');
    function avia_add_content_font($fonts)
    {
    
    $fonts['PT Sans'] = 'PT Sans:400,700,400italic,700italic';
    $fonts['PT Sans Narrow'] = 'PT Sans Narrow:400,700';
    return $fonts;
    }

    The PT Sans Narrow is at the very bottom of heading font. Please remove browser cache then reload the page after you selected the fonts.

    Best regards,
    Ismael

    #206425

    Unfortunately, I’ve tried exactly this and it hasn’t worked. Where in the theme is your master list of google fonts stored? I’d like to edit the source directly.

    Thanks,

    Barry

    #206432

    Yeah. To confirm, I just emptied my cache. I need a better way to add webfonts. Please advise.

    Thanks,

    Barry

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘best way to call new google font stylesheet’ is closed to new replies.