Support

Account

Home Forums Gutenberg Core spacing supports for ACF blocks

Solving

Core spacing supports for ACF blocks

  • Hello.
    Building some custom ACF blocks, and can’t get the spacing attribute to show in the php template ie frontend.

    My block.json looks like:

    "supports": {
       "align": true,
       "spacing": {
          "margin": true
       }
    }

    I can get the spacing to work in the editor, but nothing is being set in the frontend. I tried in my php template:

    $classes .= ' ' . $block['style']['margin'];
    $classes .= ' ' . $block['spacing']['margin'];
    $classes .= ' ' . $block['spacing'];
    $classes .= ' ' . $block['margin'];

    but none of them spit out a anything in the frontend.

    Any help would be appreciated

  • Try this:

    $classes .= ' ' . $block['style']['spacing']['margin']['top'];

  • Hi,

    thanks but it is not working.

  • Having a similar issue where any spacing attributes I try to set via the Gutenberg editor don’t render on the front-end.

    if( !empty($block['style']['paddingTop']) ) {$styles .= 'padding-top:' . $block['style']['paddingTop'] . ';';}

    Any ideas?

  • Try this

    if( !empty($block['style']['spacing']['padding']) ) {$styles .= 'padding-top:' . $block['style']['spacing']['padding']['top'] . ';';}

  • Worked a treat! Thank you.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.