/card/attributes

DescriptionDescription

This filter is called before a card is lay out.

It allows to modify card attributes like the number of columns or rows, content_background, overlay_background, content_color_scheme, overlay_color_scheme or class.

ArgumentsArguments

ArgumentTypeDescription
$attsarrayHolds card attributes
$cardobject Holds card layout (layers/blocks) definition

ExampleExample

PHP
functions.php
function prefix_card_attributes( $atts, $card ) {

	// We get post in the custom loop of the plugin.
	$post = wpgb_get_post();

	// If current post ID is equal to 1, change number of rows/columns.
	if ( 1 === $post->ID ) {

		$atts['rows'] = 1;
		$atts['columns'] = 2;

	}

	return $atts;

}

add_filter( 'wp_grid_builder/card/attributes', 'prefix_card_attributes', 10, 2 );