[Resolved] How to set default padding on Container Block in GenereateBlocks

Home Forums Support [Resolved] How to set default padding on Container Block in GenereateBlocks

Home Forums Support How to set default padding on Container Block in GenereateBlocks

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1284605
    Mark

    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.

    #1284663
    Leo
    Staff
    Customer Support

    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 πŸ™‚

    #1284710
    Mark

    Thanks Leo. Looking forward to the pro version.

    #1284714
    Leo
    Staff
    Customer Support

    Us too!

    #1522225
    Simon

    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.

    #1522838
    Leo
    Staff
    Customer Support

    Thanks Simon!

    #1668505
    Morgan

    Thanks! This is exactly what I needed!

    #1668510
    Leo
    Staff
    Customer Support
    #1669841
    Morgan

    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.

    #1669892
    Leo
    Staff
    Customer Support

    The filter solution provided above is the best πŸ™‚

    #1670101
    Morgan

    Haha, because that’s exactly what I was asking for.
    Having some sleep helped, with the whole making-sense-of-things-caper.
    Thanks πŸ™‚

    #1670869
    Leo
    Staff
    Customer Support

    No problem πŸ™‚

    #1858807
    Shaun

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

    #1859327
    Leo
    Staff
    Customer Support

    Take a look at this:
    https://github.com/tomusborne/generateblocks/blob/c2aad72f6868001c6f7fa9b606cafef511eebd1b/includes/defaults.php#L49-L52

    Please open a support topic in GB’s support forum if you need further help:
    https://wordpress.org/support/plugin/generateblocks/

    We are trying to build a knowledge base there as well.

    Thanks!

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘How to set default padding on Container Block in GenereateBlocks’ is closed to new replies.