Privacy PHP Beginner

Remove Google Fonts From the Font Library

Remove the Google Fonts collection from the Site Editor's font library, so nobody installs fonts from Google by mistake.

Tested on WordPress 7.1 PHP 8.3 No plugin needed Updated
functions.php 5 lines
add_action( 'init', function (): void {
	if ( function_exists( 'wp_unregister_font_collection' ) ) {
		wp_unregister_font_collection( 'google-fonts' );
	}
}, 20 );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

The font library lists Google Fonts to install. Installing copies the files to your site, but browsing the list loads previews from Google, and some site owners would rather not offer Google as a source at all. This snippet removes the collection while keeping uploads of your own font files.

How it works

WordPress registers Google Fonts as a font collection called google-fonts. wp_unregister_font_collection() removes it, so the “Install Fonts” tab no longer lists it. The “Upload” tab still works.

Things to watch

  • Fonts already installed from the library stay installed and are served from your own site.
  • To turn the whole font library off, use “Turn Off the Font Library”.

How to test it

Open Appearance → Editor → Styles → Typography → Manage fonts. The Google Fonts tab should be gone.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only