Plugin Support
ying
(@yingscarlett)
Do you mean you want to set a max-width for the container block? or all GB blocks? CSS would be an easy option.
Let me know π
Thread Starter
Stefano
(@stefacchio)
I mean to set the global max-width value into GB Settings sections. I wanna keep a universal place where set this value, at the moment I have a custom option in WP Customizer to set it.
Maybe can I set global max-width with some code in functions.php by first retrieving the value from the customiser and then injecting it into generateblock?
Thanks
-
This reply was modified 11 months, 3 weeks ago by
Stefano.
Plugin Support
ying
(@yingscarlett)
I actually don’t quite get your idea. The max-width is not an essential attribute for GB blocks, we adds that only when it’s needed.
However, GB has the global max-width option at dashboard> generateblocks > settings.
Let me know if that works for you.
Thread Starter
Stefano
(@stefacchio)
it’s very usefull because with a max width wrapper set on the theme, when I use a full width block/container and an inner container, to keep the same width of the template theme, it’s necessary set the max width on inner container.
Thread Starter
Stefano
(@stefacchio)
what?
I Just need something like a GB filter to set the global max width by code….
Plugin Support
ying
(@yingscarlett)
You can set the global max width in GB’s setting, that doesn’t work?
Thread Starter
Stefano
(@stefacchio)
Maybe I didn’t explain myself well, sorry but I’m not English. I’ll try to explain myself better, I Simply need to set the global max-width value via code in dashboard> generateblocks> settings
Plugin Support
ying
(@yingscarlett)
Thread Starter
Stefano
(@stefacchio)
yes It works but i don’t want set It manually because I already have to set It in my custom theme option, so I just want set it once, and automatically set it into gb
Thread Starter
Stefano
(@stefacchio)
instead of a get function Is there a set function? Or maybe you can read It from theme.json?
Plugin Support
Alvind
(@alvindcaesar)
Hi there,
If you defined the max-width value inside the settings array in theme.json
, you can try using the wp_get_global_settings
function to retrieve the value.
Or, why not just use the generateblocks_global_container_width
filter hook and return the max-width value you set? That is simpler in my opinion.
Thread Starter
Stefano
(@stefacchio)
I can’t find generateblocks_global_container_width
, hoe use It?
however I want to set global width automatically Reading a value from my theme option
Plugin Support
ying
(@yingscarlett)
The link I provided should take you right to the line 1193 of the GB file, and the filter generateblocks_global_container_width
should be on that line.
You can do something like this:
add_filter('generateblocks_global_container_width', function() {
return 1500;
});
Or you can add your own function which fetch your theme’s max-width to the filter.
Thread Starter
Stefano
(@stefacchio)
It works! the only small problem is that the set value is visible in the blocks but in the settings is not read and whatever value is then entered on the settings page is not read.
Is there no way to enter the value in the db or in the settings page?