- This topic has 7 replies, 3 voices, and was last updated 2 years, 4 months ago by Leo.
-
AuthorPosts
-
November 7, 2021 at 3:25 am #1994548Ian
So using this to set default GB padding used to work. On a new site, I could not even get functions.php to save. Forced it through using SFTP and now containers still do not contain any padding. Here is what used to work, any ideas?
add_filter( ‘generateblocks_defaults’, function( $defaults ) {
$defaults[‘container’][‘paddingTop’] = ’40’;
$defaults[‘container’][‘paddingRight’] = ’25’;
$defaults[‘container’][‘paddingBottom’] = ’40’;
$defaults[‘container’][‘paddingLeft’] = ’25’;return $defaults;
} );November 7, 2021 at 9:23 am #1994955DavidStaffCustomer SupportHi there,
that snippet does still work. For reference i added it back in a code block to maintain formatting:
add_filter( 'generateblocks_defaults', function( $defaults ) { $defaults['container']['paddingTop'] = '40'; $defaults['container']['paddingRight'] = '25'; $defaults['container']['paddingBottom'] = '40'; $defaults['container']['paddingLeft'] = '25'; return $defaults; } );
It updates the default values – so it won’t affect any Container already added to the site where the default values were updated. Test it by adding a new container block to a page.
November 7, 2021 at 11:28 am #1995052IanThat is interesting. On a new site, I tried adding this into functions.php via WordPress and it would not save. I then forced it in using SFTP and new Containers would not show any numbers inside Spacing. It works well on a previous site but not this one. I wonder if it is a PHP 8 issue. Switched back to PHP 7.4 and added a child theme and the site loads again but just in case this helps, here is the error:
“FastCGI sent in stderr: “PHP message: PHP Warning: Undefined array key “width” in /var/www/domain.com/htdocs/wp-content/themes/generatepress/inc/structure/header.php on line 137PHP message: PHP Warning: Undefined array key “height” in /var/www/domain.com/htdocs/wp-content/themes/generatepress/inc/structure/header.php on line 138″ while reading upstream”
Even switching back to PHP 7.4, still cannot save to functions.php with this error popping:
“Unable to communicate back with site to check for fatal errors, so the PHP change was reverted.”
Odd?
November 7, 2021 at 12:21 pm #1995096LeoStaffCustomer SupportCan you make sure David’s function is added using one of these methods:
Adding PHP: https://docs.generatepress.com/article/adding-php/It cannot be added to the parent theme’s
function.php
.November 7, 2021 at 2:24 pm #1995155IanThanks Leo! Using Code Snippets worked. Wonder why adding to functions.php in the child theme no longer works for this latest build. It did last month on a previous site. But thank you!
One more question. Is there a way to use this function and have a default where any new container is automatically tied to a Global Style? I would say 90% of my GB Containers would use this setup.
November 7, 2021 at 2:50 pm #1995174LeoStaffCustomer SupportCan you open a support topic in GB’s support forum here?
https://generateblocks.com/support/Thanks!
November 7, 2021 at 2:50 pm #1995176IanAfter building a bit more, I think I should probably use Global Style instead of the function to do this. Will be easier to update in the future. Thank you!
November 7, 2021 at 3:00 pm #1995185LeoStaffCustomer SupportNo problem 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.