Hi there,
Did you wrap the filter with the wp hook like this?
add_action( 'wp', function() {
add_filter( 'generate_media_queries', function( $args ) {
$args['desktop'] = '(min-width:1081px)';
$args['tablet_only'] = '(max-width:1080)';
$args['tablet'] = '(min-width: 811px) and (max-width: 1080px)';
$args['mobile'] = '(max-width:810px)';
return $args;
} );
}, 20 );
Hi @alvindcaesar,
Thanks for the tip, unfortunately it doesn’t help, the desktop breakpoint stuck to 1024px for instance.
I also tried different action hooks: init, root…
Hi there,
that filter applies to the dynamic CSS generated by the Theme Customiser, for example the Typography settings. Primary Nav has its own breakpoint in the Customizer > Layout > Primary Nav. Blog columns and sidebar layouts generally require some CSS.
Anything content related such as blocks , those styles are not defined by GP except where there is CSS inheritance such as the aforementioned typography.
For the GenerateBlocks plugin it has its own filter eg.:
add_action( 'wp', function() {
add_filter( 'generateblocks_media_query', function( $query ) {
$query['desktop'] = '(min-width: 1025px)';
$query['tablet'] = '(max-width: 1024px)';
$query['tablet_only'] = '(max-width: 1024px) and (min-width: 768px)';
$query['mobile'] = '(max-width: 767px)';
return $query;
} );
}, 20 );
Hi @diggeddy,
Thanks for your info.
Unfortunately i’m not sure to understand.
As i mentioned above, none of the filters above using the generate_media_queries hook works for me.
For instance, i’m expecting the H1, H2… font-size to change in frontend on 1080 and 810 px breakpoints, and it still changes at GP default 1024 and 768 px breakpoints.
This custom breakpoints option seems pretty basic to me, using it in other themes such as WP Pagebuilder Framework, Beaver Builder Theme… alongisde with Beaver Builder.
But it’s not available in the GeneratePress theme, making it mandatory the GP default 1024/768 breakpoints, unless a PHP filter actually works(?)
ying
(@yingscarlett)
Hi there,
Alvind’s code should work, I just tested on my site. If it doesn’t work for you, please make sure all cache is cleared.
And yes, unfortunately we don’t offer the option to change media query in the customizer. We keep our theme light and fast by not adding everything to it, hope that’s understandable.
Hi,
So i tested the GP custom breakpoints filter again (Alvind’s code above) but in a very basic WP site this time, to make sure no custom code was interfering, and it still doesn’t work unfortunately.
Steps:
1 . Set Heading 1 (H1) responsive font sizes in GP Customizer.
https://share.cleanshot.com/01jvBGn6
2 . Add the GP filter in function.php to set the tablet breakpoint to 1080px instead of 1024px (GP default) and mobile to 810px instead of 768px (GP default)
https://share.cleanshot.com/sGjkqztF
3 . Check H1 font size in frontend at the different breakpoint
https://share.cleanshot.com/CK174464
https://share.cleanshot.com/tV8Dqp9j
https://share.cleanshot.com/tV7vmLzM
As you can see on the screenshots, the H1 Heading changes font size when reaching the GP default breakpoints (1024/768), not the custom breakpoints (1080/810).