/grid/settings

DescriptionDescription

This filter is called every time grid settings are queried before to render or refresh grid (when filering with facets).

It allows to dynamically modifies settings of a grid. It can be pretty useful to use the same grid on different pages/posts with different behaviours.

ArgumentsArguments

ArgumentTypeDescription
$settings arrayHolds grid settings

ExampleExample

PHP
functions.php
function prefix_grid_settings( $settings ) {

	// If it matches grid id 1, we add a layout breakpoint.
	if ( 1 === $settings['id'] ) {

		$settings['card_sizes'][] = [
			'browser' => 1140, // Browser width in pixels.
			'columns' => 4,    // Number of columns (Masonry/Metro layouts).
			'height'  => 240,  // Row height in pixels (Justified layout).
			'gutter'  => 28,   // Card spacing in pixels.
			'ratio'   => [     // Card aspect ratio (Metro layout).
				'x' => 4,
				'y' => 3,
			],
		];
	}

	return $settings;

}
add_filter( 'wp_grid_builder/grid/settings', 'prefix_grid_settings' );