-
AuthorPosts
-
December 7, 2016 at 11:28 am #721425
Hi
I am trying to apply different fonts to different text boxes. I have created Custom CSS Class for a text box, e.g. ‘georgia’, and then put this in Custom CSS:
#top .georgia {
font-family: “Georgia”!important;
}This works fine with any Web save fonts but I can’t get it to work with Google fonts. Eg, if I try this
#top .cardo {
font-family: “Cardo”!important;
}
the font is not applied.You can see an e.g. on the link attached.
How can I make this work with Google fonts?
many thanks
Peter
December 8, 2016 at 5:43 am #721793Hi Peter,
How are you importing the font? You could try this in Quick CSS to see if you have any luck with it:
@import url('https://fonts.googleapis.com/css?family=Cardo');
Best regards,
RikardDecember 8, 2016 at 12:17 pm #721902Hi Rikard
I’m afraid that didn’t make any difference.
I am using the Google fonts installed with Enfold and ones I have added via the functions.php.
many thanks
Peter
December 11, 2016 at 7:49 am #722790Hi,
How are you loading the fonts? Please try this in the functions.php file.
add_action('wp_head','hook_font'); function hook_font() { $output = "<link rel='stylesheet' id='avia-google-webfont' href='//fonts.googleapis.com/css?family=Open+Sans:300,700' type='text/css' media='all'/> "; echo $output; }
Adjust the href value.
Best regards,
IsmaelDecember 12, 2016 at 12:53 pm #723089Hi Ismael
That doesn’t seem to make any difference.I am loading the extra Google fonts in the functions.php with this:
add_filter( ‘avf_google_heading_font’, ‘avia_add_heading_font’);
function avia_add_heading_font($fonts)
{
$fonts[‘Slabo’] = ‘Slabo’;
$fonts[‘Sintony’] = ‘Sintony’;
$fonts[‘Mali’] = ‘Mali’;
$fonts[‘Poppins’] = ‘Poppins’;
return $fonts;
}add_filter( ‘avf_google_content_font’, ‘avia_add_content_font’);
function avia_add_content_font($fonts)
{
$fonts[‘Slabo’] = ‘Slabo’;
$fonts[‘Sintony’] = ‘Sintony’;
$fonts[‘Mali’] = ‘Mali’;
$fonts[‘Poppins’] = ‘Poppins’;
return $fonts;
}many thanks
Peter
December 14, 2016 at 3:03 pm #724290Hi,
Please try adding following code to Functions.php file
function avia_custom_cardo_font() { wp_enqueue_style( 'Lato font', 'https://fonts.googleapis.com/css?family=Cardo' ); } add_action( 'wp_enqueue_scripts', 'avia_custom_cardo_font' );
Then following code should work
#top .cardo { font-family: "Cardo"!important; }
If that too does not help, please create a temporary admin login and post it here privately
Best regards,
YigitDecember 15, 2016 at 3:54 am #724721Hi Yigit
That doesn’t seem to be working. I have attached the login in details.
Just to clarify things – as it might be that there is a better way to achieve what I am trying to do – I have a client who wants a website demonstrating lots of different font combinations. So I want to be able to apply various different fonts to text boxes and elements.many thanks
Peter
December 17, 2016 at 10:08 am #725661Hi,
We replaced the code in the functions.php file. The fonts are now loaded inside the head tag.
add_action('wp_head','hook_font'); function hook_font() { $output = " <link rel='stylesheet' id='avia-google-webfont' href='https://fonts.googleapis.com/css?family=Slabo' type='text/css' media='all'/>\n"; $output .= " <link rel='stylesheet' id='avia-google-webfont' href='https://fonts.googleapis.com/css?family=Cardo' type='text/css' media='all'/>\n"; $output .= " <link rel='stylesheet' id='avia-google-webfont' href='https://fonts.googleapis.com/css?family=Sintony' type='text/css' media='all'/>\n"; echo $output; }
Best regards,
IsmaelDecember 21, 2016 at 7:28 pm #727247Hi
I will try that out. Many thanks for your help.
Peter
December 21, 2016 at 10:48 pm #727326Hi!
Please do keep us updated Peter, if you need something else from us
Thanks a lot for your patience and understanding
Cheers!
Basilis -
AuthorPosts
- You must be logged in to reply to this topic.