Adding Google Fonts to your WordPress site can enhance it’s aesthetics and improve readability.
Choose Your Google Fonts
- Visit Google Fonts: Go to Google Fonts.
- Select Fonts: Browse through the available fonts and select the ones you like by clicking on the “+” icon. This will add them to a collection at the bottom of the page.
- Customize Your Selection: Once you’re done selecting, click on the “Selected Family” bar at the bottom of the screen.
- Copy the Embed Code: Under the “Embed” tab, you’ll see a snippet code. Copy the <link> tag provided.
Add the Google Fonts Link to the WordPress
You can add the Google Fonts link in two main ways: through the theme’s functions.php file or by using a plugin.
Method 1: Using functions.php
- Access Theme Editor: Log in to your WordPress admin dashboard. Go to Appearance > Theme Editor.
- Open functions.php: In the right sidebar, find and click on functions.php.
- Add the Code: At the end of the file, add the following code snippet, replacing YOUR_FONT_URL with the link you copied from Google Fonts:
function add_google_fonts() { wp_enqueue_style('google-fonts', 'YOUR_FONT_URL', false); } add_action('wp_enqueue_scripts', 'add_google_fonts');
- Save Changes: Click “Update File” to save your changes.
Method 2: Using a Plugin
If you prefer not to edit code, you can use a plugin like Easy Google Fonts.
- Install the Plugin:
- Go to Plugins > Add New.
- Search for “Easy Google Fonts.”
- Install and activate the plugin.
- Configure the Plugin:
- Go to Appearance > Customize.
- Click on Typography (added by the plugin).
- Select the font you want to use for various elements (like headings, paragraphs, etc.).
- Publish Changes: Once you’re satisfied with your selections, click “Publish.”
Apply Google Fonts in Your Theme
Now that you’ve added Google Fonts to your site, you can apply them in your theme’s CSS.
- Go to Customizer: Navigate to Appearance > Customize.
- Additional CSS: Click on “Additional CSS.”
- Add CSS Rules: Use CSS to specify the Google Fonts for different elements. For example:
body { font-family: 'Your Selected Font', sans-serif; } h1, h2, h3 { font-family: 'Your Selected Font', serif; }
- Save Changes: Click “Publish” to save your custom CSS.
Clear Cache
If you’re using a caching plugin, clear your site’s cache to ensure the changes take effect.