There are various techniques for changing the fonts on a WordPress site, such as installing a new theme. If you don't like the fonts that come with the theme, you can always replace them with custom Google fonts. Google Fonts, also known as Google Web Fonts, is a set of interactive application programming interfaces that allow users to incorporate web fonts into their websites. This article will show you how to add Google Fonts to WordPress using a short script.
On the Theme Editor , select the Theme you want to edit from the dropdown:
The files for this selected theme are listed on the right column under Theme Files. Click on the file named “functions.php”:
Add this code snippet / function at the bottom of your functions.php file:
function add_google_fonts() { wp_register_style('OpenSans', '//fonts.googleapis.com/css?family=Open+Sans:400,600,700,800'); wp_enqueue_style('OpenSans');} add_action( 'wp_print_styles', 'add_google_fonts' );
The above function uses 'wp_enqueue_style' tells WordPress to use this stylesheet (specified in the code above) inside the header of every page of your wordpress website.Open the CSS file and add the following code to use the Google Font:
body { font-family: 'Open Sans', sans-serif; font-size: 20px; color: #000000; }
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.
We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.