-
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.
-
Fernando
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. -
Fernando
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: NoJust to clarify – I’m talking about this…
-
Fernando
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.
-
Ah ok thanks. 🙂
-
Fernando
You’re welcome! 🙂
- You must be logged in to reply to this topic.