Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Removing fonts from Font Family dropdown

  • Hey folks. Apologies if this is an easy one but I did a search and couldn’t find an answer.

    I want to limit font choices in WordPress edit screens (including Generateblocks) to fonts that are loaded in the GP Typography Manager in the Customiser.

    eg. on my site I have Barlow and Montserrat loaded and do not want my client to have access to a plethora of options. They should be limited to the fonts in the brand.

  • Hi Andrew,

    For GP, this is the filter for that:

    add_action( 'customize_controls_print_footer_scripts', function() {
    	?>
    	<script>
    		wp.hooks.addFilter(
    			'generate_font_manager_system_fonts',
    			'your/namespace',
    			( $fonts ) => [
    				{ value: 'Test', label: 'Test Font' },
    				{ value: 'Another', label: 'Another Font' },
    			]
    		);	
    	</script>
    	<?php
    } );

    Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets

    For, GenerateBlocks, there is no filter yet but there will be in the upcoming update. Reference: https://github.com/tomusborne/generateblocks/pull/1010

  • Thanks Ferdinand. It doesn’t seem to have done anything.
    I’ve added the code to my child theme; changed names and labels to the 3 I want loaded; Flushed server and browser caches but the Font Family list remains unchanged.

  • Add this as well:

    add_filter( 'generate_font_manager_show_google_fonts', '__return_false' );

    Let us know how it goes.

  • No luck unfortunately. Nor do I actually have 2 of 3 of my loaded fonts in the list come to think of it.
    Montserrat: Yes
    Barlow: No
    Shrikhand: No

    Just to clarify – I’m talking about this…

    Font Family list

  • That’s GenerateBlocks’ settings. The filter I provided is for GeneratePress. As mentioned, the filter for GenerateBlocks typography list will come out in the upcoming update. For now, there is no filter yet.

    The upcoming update is already in the beta phase of testing though.

  • You’re welcome! 🙂

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.