- This topic has 9 replies, 3 voices, and was last updated 1 year, 4 months ago by David.
-
AuthorPosts
-
June 4, 2022 at 3:46 am #2243165bjbowen
Hi there! I added the Local font per the instructions here: https://docs.generatepress.com/article/adding-local-fonts/ (As I have done before without any problem)
The fonts display correctly in the Customizer and on the frontend.
But, they don’t display correctly in the Editor.
I added this snippet from another support thread:
add_filter( ‘generate_editor_styles’, function( $editor_styles ) {
$editor_styles[] = ‘wp-content/themes/generatepress/assets/css/admin/editor-style.css’;return $editor_styles;
} );That had no effect and I’m not even sure if that’s the correct editor-style.css to call.
The local fonts are Anton and Open Sans.
June 4, 2022 at 9:23 am #2243509DavidStaffCustomer SupportHi there,
couple if options:
1. If you added your fonts @font-face CSS in the Customizer > Additional CSS then add this snippet:
add_filter( 'block_editor_settings_all', function( $editor_settings ) { $css = wp_get_custom_css_post()->post_content; $editor_settings['styles'][] = array( 'css' => $css ); return $editor_settings; } );
OR
2. If you added the @font-face to a child theme style.css then you add this snippet:
add_filter( 'generate_editor_styles', function( $editor_styles ) { $editor_styles[] = 'style.css'; return $editor_styles; } );
June 6, 2022 at 5:01 am #2244883bjbowenThank you. I added #2 to my functions.php in the child theme.
I Regenerated CSS in Generate Blocks.
I double checked everything I knew to check and refreshed the page a few times. Still the fonts aren’t showing in the editor.
hmmmm
June 6, 2022 at 5:16 am #2244897DavidStaffCustomer SupportOk in your functions.php you have this:
add_filter( 'generate_editor_styles', function( $editor_styles ) { $editor_styles[] = 'wp-content/themes/generatepress/assets/css/admin/editor-style.css'; return $editor_styles; } );
and
/* Add local fonts to the editor */ add_filter( 'generate_editor_styles', function( $editor_styles ) { $editor_styles[] = 'fonts.css'; return $editor_styles; } );
Remove BOTH of them.
And just add this:
add_filter( 'generate_editor_styles', function( $editor_styles ) { $editor_styles[] = 'style.css'; return $editor_styles; } );
June 6, 2022 at 5:24 am #2244900bjbowenThat did it!
Now I’m wondering why I didn’t have this problem with the last site I built. hmmm
Thank you
June 6, 2022 at 5:51 am #2244919DavidStaffCustomer SupportWP made some changes to how editor styles were loaded, particularly in the mobile / tablet previews.
The method i provided covers all that and ties up any other loose ends from WP updates.Glad to be of help.
November 10, 2022 at 3:11 am #2409535PeterHi David,
using GP with a child theme I encountered this thread’s issue just yesterday and was quite irritated at first but luckily that first snippet of yours solved it right away – thanks a lot!
November 10, 2022 at 6:40 am #2409787DavidStaffCustomer SupportGlad to hear you found that of use!
November 11, 2022 at 4:15 am #2411084bjbowenHi David,
Will I need to add this bit of code to my starter site or will this be added in a GP update?
November 11, 2022 at 5:10 am #2411145DavidStaffCustomer SupportWill I need to add this bit of code to my starter site or will this be added in a GP update?
Yes, you will need to add it if you want to load your child theme stylesheet in the editor.
No, this code won’t be added to the theme as its optional and we do not know the name of the child theme stylesheet(s) the user may or may not want to load 🙂In the future we will add an option to GP Premium that manages localisation of fonts for you and that will include options to load them in the editor.
-
AuthorPosts
- You must be logged in to reply to this topic.