Button Block Not Inheriting GeneratePress Button Style
-
Hey guys,
The button block doesn’t seem to be inheriting the style I’ve set in GeneratePress. Any ideas on what might be happening?
-
Hi there,
It won’t do that by default.
However, you can tell it to: https://generatepress.com/forums/topic/add-custom-css-selector-to-the-button-selector/#post-1322768
Hope this helps! 🙂
Ah I see. So I’ve added the filter and it is working for the color but I’m wondering if it’s possible to inherit the font of the button settings in GeneratePress as well.
Figured out a simple enough solution for now. Just add the
buttonclass to the button block.Yea, that’s a simple way to do it, although it does involve manually adding the class.
We can extend the filter I provided to include typography options as well if you’d like 🙂
That would be great as well! Thanks Tom
Let’s give this a shot:
add_filter( 'generateblocks_defaults', function( $defaults ) { $color_settings = wp_parse_args( get_option( 'generate_settings', array() ), generate_get_color_defaults() ); $typography_settings = wp_parse_args( get_option( 'generate_settings', array() ), generate_get_default_fonts() ); $defaults['button']['backgroundColor'] = $color_settings['form_button_background_color']; $defaults['button']['backgroundColorHover'] = $color_settings['form_button_background_color_hover']; $defaults['button']['textColor'] = $color_settings['form_button_text_color']; $defaults['button']['textColorHover'] = $color_settings['form_button_text_color_hover']; $defaults['button']['paddingTop'] = '10'; $defaults['button']['paddingRight'] = '20'; $defaults['button']['paddingBottom'] = '10'; $defaults['button']['paddingLeft'] = '20'; $defaults['button']['fontSize'] = $typography_settings['buttons_font_size']; $defaults['button']['fontWeight'] = $typography_settings['buttons_font_weight']; $defaults['button']['textTransform'] = $typography_settings['buttons_font_transform']; return $defaults; } );Works like a charm. Thank you Tom! Really enjoying GB!
Awesome – thank you! 🙂
@edge22 it seems like the only things that isn’t being inherited is the font-family. I tried this but it doesn’t seem to be working.
add_filter( 'generateblocks_defaults', function( $defaults ) { $color_settings = wp_parse_args( get_option( 'generate_settings', array() ), generate_get_color_defaults() ); $typography_settings = wp_parse_args( get_option( 'generate_settings', array() ), generate_get_default_fonts() ); $defaults['button']['backgroundColor'] = $color_settings['form_button_background_color']; $defaults['button']['backgroundColorHover'] = $color_settings['form_button_background_color_hover']; $defaults['button']['textColor'] = $color_settings['form_button_text_color']; $defaults['button']['textColorHover'] = $color_settings['form_button_text_color_hover']; $defaults['button']['paddingTop'] = '10'; $defaults['button']['paddingRight'] = '20'; $defaults['button']['paddingBottom'] = '10'; $defaults['button']['paddingLeft'] = '20'; $defaults['button']['fontFamily'] = $typography_settings['buttons_font_family']; $defaults['button']['fontSize'] = $typography_settings['buttons_font_size']; $defaults['button']['fontWeight'] = $typography_settings['buttons_font_weight']; $defaults['button']['textTransform'] = $typography_settings['buttons_font_transform']; return $defaults; } );I added the
$defaults['button']['fontFamily'] = $typography_settings['buttons_font_family'];line.Any thoughts?
Try this:
$defaults['button']['fontFamily'] = $typography_settings['font_buttons'];Let me know 🙂
Perfect! Thanks Tom
No problem! 🙂
The topic ‘Button Block Not Inheriting GeneratePress Button Style’ is closed to new replies.