How to Add Custom Fonts to WordPress

Updated on

· Ga Satrya · WordPress · 7 min read
Decoration
Table of Contents

Are you tired of the same old fonts on your WordPress website? Want to add a unique touch to your site's typography? You're in the right place! This comprehensive guide will walk you through the process of adding custom fonts to WordPress, from start to finish.

Whether you're a beginner just starting out with WordPress or an intermediate user looking to expand your skills, this guide has got you covered. We'll explore different methods, share practical examples, and provide actionable tips to help you customize your site's typography like a pro.

Why Add Custom Fonts to WordPress?

Before we dive into the how-to, let's quickly discuss why you might want to add custom fonts to your WordPress site:

  1. Brand Identity: Custom fonts can help reinforce your brand's unique personality and style.
  2. Improved Readability: The right font can make your content easier to read and more engaging.
  3. Stand Out from the Crowd: Custom typography sets your site apart from others using standard fonts.
  4. Consistency: Using custom fonts ensures consistency across your website and other marketing materials.

Now that we understand the benefits, let's explore how to add custom fonts to WordPress.

How to Add Custom Fonts to WordPress

Custom Fonts in WordPress: A Step-by-Step Tutorial

Method 1: Using a Plugin to Add Custom Fonts

For beginners, using a plugin is the easiest way to add custom fonts to WordPress. We'll use the popular Use Any Font plugin for this example.

Key Features of Use Any Font Plugin

  1. Easy Font Upload: Supports ttf, otf, woff, and woff2 font formats. Only one format needs to be uploaded; others are auto-converted.

  2. Fast Font Loading: Automatically converts fonts to compressed woff2 format for 30% faster loading.

  3. SEO Friendly & GDPR Compliant: Fonts are embedded with @font-face CSS and stored on your server.

  4. Large Font Upload: Allows uploads up to 25 MB.

  5. Font Variations: Upload multiple styles and weights of the same font.

  6. Wide Compatibility: Works with popular page builders and themes like Divi, Elementor, Beaver Builder, and more.

  7. Language Support: Assign fonts based on language with WPML and Polylang plugins.

  8. Font Display Property: Manage font loading behavior in @font-face.

  9. Predefined Fonts: Access to 23,871+ predefined fonts available for both free and commercial use.

By using the Use Any Font plugin, you can easily add custom fonts to your WordPress site without needing to edit any code. The plugin's features make it a powerful and user-friendly solution for customizing your site's typography.

Step 1: Install and Activate the Plugin

  1. Log in to your WordPress dashboard.
  2. Go to Plugins > Add New.
  3. Search for "Use Any Font".
  4. Click "Install Now" and then "Activate".
Use Any Font Installation

Step 2: Upload Your Custom Font

  1. Click "Use Any Fonts" menu.
  2. You must generate API key first. Click "Generate Free Lite API Key" .
  3. Click on "Upload Fonts".
  4. Upload your font file (in .woff or .woff2 format for best compatibility).
  5. Give your font a name and click "Upload".
Use Any Font Settings

Step 3: Assign the Font to Elements

  1. Click "Assign Font"
  2. In the plugin settings, you'll see a list of elements (like body text, headings, etc.).
  3. Select your uploaded font from the dropdown menu for each element you want to change.
  4. Click "Save Settings".

And that's it! Your custom font is now live on your WordPress site.

Method 2: Manually Adding Custom Fonts to WordPress

For intermediate users or those who prefer more control, you can manually add custom fonts to WordPress. This method involves editing your theme's files, so make sure to back up your site before proceeding.

Step 1: Upload Your Font Files

  1. Convert your font to web-friendly formats (.woff and .woff2) using a tool like Font Squirrel.
  2. Upload the font files to your theme folder (wp-content/themes/your-theme-name/fonts/).

Step 2: Add @font-face Rule to Your Stylesheet

  1. Open your theme's style.css file.
  2. Add the following code, replacing the file paths and font names with your own:
@font-face {
  font-family: 'YourFontName';
  src:
    url('fonts/your-font.woff2') format('woff2'),
    url('fonts/your-font.woff') format('woff');
  font-weight: normal;
  font-style: normal;
}

Step 3: Use the Font in Your CSS

Now you can use your custom font anywhere in your CSS like this:

body {
  font-family: 'YourFontName', sans-serif;
}

Method 3: Using Google Fonts

Google Fonts offers a vast library of free, web-optimized fonts that are easy to integrate into WordPress.

Step 1: Choose Your Google Font

  1. Visit Google Fonts.
  2. Select the font you want to use.
  3. Click the "Get Font" button to add it to your selection.
Get Google Fonts Button

Step 2: Get the Embed Code

  1. Click on the "Embed Code" button.
  2. Copy the provided <link> code.

For example:

<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
  href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"
  rel="stylesheet"
/>

Step 3: Add the Font to WordPress

  1. Go to your WordPress dashboard.
  2. Navigate to Appearance > Theme Editor.
  3. Find the header.php file in your theme files.
  4. Paste the <link> code just before the closing </head> tag.
  5. Click "Update File".

Step 4: Use the Font in Your CSS

Now you can use the Google Font in your style.css like this:

body {
  font-family: 'Font Name', sans-serif;
}

Replace 'Font Name' with the actual name of your chosen Google Font.

Best Practices for Using Custom Fonts

  1. Limit the number of fonts: Use no more than 2-3 different fonts on your site to maintain a clean, cohesive look.
  2. Consider loading times: Custom fonts can slow down your site, so use them judiciously.
  3. Ensure readability: Choose fonts that are easy to read, especially for body text.
  4. Test on multiple devices: Make sure your custom fonts look good on desktop, tablet, and mobile.
  5. Provide fallback fonts: Always include web-safe fallback fonts in case your custom font fails to load. For example sans-serif for Roboto or serif for Lora.

Troubleshooting Common Issues

  1. Font not displaying: Make sure the file paths in your CSS are correct.
  2. Slow loading times: Optimize your font files and consider using a CDN.
  3. Inconsistent display across browsers: Use multiple font formats (.woff2, .woff) for better compatibility.
  4. Font looks different than expected: Check if you're using the correct font weight and style.

Conclusion

Adding custom fonts to WordPress is a great way to enhance your site's visual appeal and reinforce your brand identity. Whether you choose to use a plugin, manually add fonts, or integrate Google Fonts, you now have the knowledge to customize your WordPress typography like a pro.

Remember to always prioritize readability and site performance when choosing and implementing custom fonts. With these tips and techniques, you're well on your way to creating a unique and engaging WordPress site that stands out from the crowd.

Happy font customizing!

Services I Offer

Discover how my expertise can elevate your online presence with tailored WordPress solutions. From development to consulting, I offer comprehensive services designed to meet your specific business needs.

WordPress Website Development

I create custom WordPress websites tailored to your business needs, ensuring a seamless user experience and a professional online presence. From design to deployment, I handle every aspect to bring your vision to life.

WordPress Theme or Plugin Development

Need a custom theme or plugin for your WordPress site? I specialize in developing unique themes and plugins that enhance functionality, improve performance, and align perfectly with your brand's aesthetics.

WordPress Consulting

Whether you need guidance on improving your current WordPress site or planning a new project, my consulting services provide expert advice and strategies to help you achieve your goals. Let's optimize your website for success.

Ongoing Maintenance and Support

I offer comprehensive maintenance and support services to keep your WordPress website secure, up-to-date, and performing at its best. From regular updates to troubleshooting, I ensure your website remains reliable and efficient.