Site logo

Archived topic

How to set default padding on Container Block in GenereateBlocks

13 replies · Started by Mark on May 14, 2020

Viewing posts 1–14 of 14

Hi Tom

I'm really enjoying using GenerateBlocks. All the blocks are extremely useful.

I notice the Container Blocks has a default of 40px padding on all sides. Is there a way to re-set the container default to 0px on all sides? I know I can create a Re-usable Block and pull that out, but I thought you might have created a way to set up preferences, or something like that, for the padding, margins, etc.

Hi there,

It's not possible currently but it will certainly be in the future (likely in the pro version).

We actually just worked out the kinks that will make this possible recently :)

Thanks Leo. Looking forward to the pro version.

Us too!

Hi Mark, Leo

I share the need to remove that automated 40px padding.

There is a solution from Tom here: https://generatepress.com/forums/topic/generateblocks-default-padding-issues/

I have successfully used it to put this code in a Code Snippet:

// Cancels the GP automated 40px padding.
add_filter( 'generateblocks_defaults', function( $defaults ) {
    $defaults['container']['paddingTop'] = '0';
    $defaults['container']['paddingRight'] = '0';
    $defaults['container']['paddingBottom'] = '0';
    $defaults['container']['paddingLeft'] = '0';

    return $defaults;
} );

It also impacts on the block editor, removing the padding, and making it impossible to see the containers. I struggled for a while... So the key point is to set the snippet to 'Only run on site front end'.

Hope that helps.

Thanks Simon!

Thanks! This is exactly what I needed!

Thanks.

Is there a way to add just the edited section of default.php, to replace/run only that section, to Code Snippets?

I.e. In this example relevant code change would be:

'paddingTop' => 0,
'paddingRight' => 0,
'paddingBottom' => 0,
'paddingLeft' => 0,

Failing that - how to add the entire file in code snippets, not conflict with existing?

This way it could persist between updates.

The filter solution provided above is the best :)

Haha, because that's exactly what I was asking for.
Having some sleep helped, with the whole making-sense-of-things-caper.
Thanks :)

No problem :)

Interesting thread. Any ideas on changing default container padding just for mobile?

This archived topic is closed to new replies.