• Resolved KS

    (@karl19)


    I’m using GeneratePress together with Kadence Blocks, which generally works fine. I’m having an issue with default bottom margins, however, where the default GP margin trumps Kadence, even when setting specific margins for a Kadence block in the admin.

    Looking online, this seems to be due to the generate_do_wp_block_margin_bottom function and the fact that it targets WP core blocks:

    if ( apply_filters( 'generate_do_wp_block_margin_bottom', true ) ) {
    $css->set_selector( '.entry-content > [class*="wp-block-"]:not(:last-child):not(.wp-block-heading)' );
    $css->add_property( 'margin-bottom', floatval( $settings['paragraph_margin'] ), false, 'em' );
    }

    Kadence uses the wp-block- prefix too and so gets targeted.

    Reading here https://generatepress.com/forums/topic/style-conflict-with-toolset/, it seems like it should be possible to disable this filter by adding:

    add_filter( 'generate_do_wp_block_margin_bottom', '__return_false' );

    but this is not working for me. If I could disable this filter, it seems like default GP styling would revert to:

    .entry-content [class*="wp-block-"]:not(:last-child)

    and this gets overwritten by inline Kadence styling.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi there,

    try reducing the priority of the hook so it fires later eg.

    add_filter( 'generate_do_wp_block_margin_bottom', '__return_false', 99 );
    Thread Starter KS

    (@karl19)

    Hi David, many thanks for the quick reply! I tried this, unfortunately it didn’t help solve the issue.

    It’s a bit odd, if I remove the actual filter in /inc/css-output.php (lines 550-553) just to test, still nothing happens and the CSS code still gets output into the inline CSS “generate-style-inline-css”. Only if I remove:

    wp_add_inline_style( 'generate-style', wp_strip_all_tags( $css ) );

    in the generate_enqueue_dynamic_css function, does I get rid of the CSS for that bottom margin. But then of course, I lose all other GP inline styling.

    Theme Author Tom

    (@edge22)

    Hi there,

    Is your dynamic CSS cached? You can check in “Customize > General > Cache dynamic CSS”. If it is, you can simply toggle the checkbox and save to clear the cache.

    Thread Starter KS

    (@karl19)

    Hello Tom, ah many thanks! I didn’t know about this dynamic caching of CSS function, even though I have built a whole bunch of sites with GP. Thanks for pointing this out!

    Theme Author Tom

    (@edge22)

    It usually clears for you when necessary, but when it comes to changing things via filters, it may need a little help.

    Glad I could help! ??

    • This reply was modified 1 year, 2 months ago by Tom.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘generate_do_wp_block_margin_bottom’ is closed to new replies.