Jump to content
Sign in to follow this  
evert100

adding google fonts

Recommended Posts

evert100

Hi iread how to add one google font through the functions.php in the base file. Works! But i cannot see how to add several of those. I tried to adthe "add_filter...." again, but it doesn't work. Please give me some clue how to manage this. Thanks. Evert

Share this post


Link to post
Share on other sites
evert100
the demo script pagelines provide in functions.php in base theme. That works, but how can i add say 10 google fonts? That's my question.

Share this post


Link to post
Share on other sites
Jenny
I add them one at a time, for example, I have: [code]add_filter ( 'pagelines_foundry', 'sofia_google_font' ); function sofia_google_font( $thefoundry ) { $myfont = array( 'Sofia' => array( 'name' => 'Sofia', 'family' => '"Sofia", cursive', 'web_safe' => true, 'google' => true, 'monospace' => false ) ); return array_merge( $thefoundry, $myfont ); }[/code] ...for each of my fonts. I'm sure they can be combined in the array but haven't looked in to doing that yet.

Jenny :: Web designer at Simple Mama (follow me at @simplemamacom)

Check out Share Me, a social sharing add-on for DMS that is super simple to set up.

Share this post


Link to post
Share on other sites
evert100
Thanks Jenny, But it still doesn't work as expected. Maybe I have a misinterpretation of your answer. My wish is to: add several google fonts through the use of the add_filter option in functions.php in the base theme. If I use your above code twice, i get a crash. That is no fonts to choose in admin pro settings Typography. Can you please provide me with one code example where you add 2 google fonts? Please give the exact code. I think i have to change something like $myfont in $myfont2 i don't know. I change some coding in php but for this i lack the knowledge. Would be great if you could help with this sample snippet code. Would adding fonts directly to class.typography.php in the includes folder be a good idea? If so, could that be done through the base theme? How? Thanks.

Share this post


Link to post
Share on other sites
Simon
You get a crash because you are copying the function, the function name has to be different every time.

Share this post


Link to post
Share on other sites
evert100
Simon, Give a snippet code. Your answer is too brief. Sorry. This doesn't work for me. Thanks.

Share this post


Link to post
Share on other sites
Simon
add_filter ( 'pagelines_foundry', '[b]sofia_google_font[/b]' ); function [b]sofia_google_font[/b]( $thefoundry ) { I have bolded the function name, if your going to repeat it to add more fonts you need to make the function name unique each time or php will produce an error just add _1 _2 _3 etc to the name in those 2 places

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×