Disable Google Fonts Loading When Using the Astra Theme

In Germany, the GDRP (in german its the “DSGVO”) permits the usage of Google Fonts. Instead, you have to host the fonts locally. The Astra Theme loads Google Fonts by default, if you don’t use the System Fonts. This is a problem in regard of GDRP.

To avoid this, you have to add the desired font files to your Astra child theme, add them to your child themes stylesheet and disable Google Fonts loading by the Astra theme. To disable loading Google Fonts by the Astra Theme, add this code to your child themes function.php:

add_filter('astra_google_fonts_selected', function($fonts) {
    return [];

In that way, you can use the customizer as normally to build and configure your desired layout. After finishing the layout, look at the sites source code to identify the loaded Google Fonts. As a next step use the google webfonts helper to generate the required CSS code and download the desired font files. Add the CSS code to your child themes CSS file and add the font files to your child theme. Now, you should be using local hosted files instead of files, loaded from Google Fonts.

Caution: There may be other plugins / code, that loads fonts by Google Fonts. Always check your requests, if all Google Fonts requests are gone!