Tagged: functions.php, google fonts
-
AuthorPosts
-
December 3, 2013 at 3:53 am #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
December 3, 2013 at 9:11 am #195682Hey 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,
IsmaelDecember 4, 2013 at 2:00 am #195930Thanks Ismael – do I need to make sure my child theme functions.php is completely empty except for this function?
December 4, 2013 at 10:15 am #196037December 4, 2013 at 10:25 am #196048just to be clear, and leave all the other code in the child theme’s funciton.php – which is the same as the parent theme?
December 5, 2013 at 6:30 am #196535Hi!
Child theme functions.php.
Regards,
JosueDecember 5, 2013 at 6:34 am #196539Hi 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?
December 5, 2013 at 6:40 am #196546Hi!
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!
JosueDecember 9, 2013 at 2:18 am #197848Thanks 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;
}December 9, 2013 at 5:47 am #197911Hi!
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,
IsmaelJanuary 7, 2014 at 7:32 pm #206425Unfortunately, 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
January 7, 2014 at 8:02 pm #206432Yeah. To confirm, I just emptied my cache. I need a better way to add webfonts. Please advise.
Thanks,
Barry
-
AuthorPosts
- The topic ‘best way to call new google font stylesheet’ is closed to new replies.