BLACK FRIDAY SALE

00000000

50% OFF - Limited Time Deal

/indexer/row

DescriptionDescription

This filter is called before a row is inserted into the index table.

It allows to modifies properties of a row like the facet_value and facet_name.

This filter should not be used to query a facet value but simply used to modify it (like formatting a date). To setup rows and facet values you should use the filter wp_grid_builder/indexer/index_object

ArgumentsArguments

ArgumentTypeDescription
$rowarrayHolds index row of the current object id
$object_idintegerPost, term or user id to index
$facetarrayHolds facet settings

ExampleExample

PHP
functions.php
function prefix_row_data( $row, $object_id, $facet ) {

	// We only process facet ID "1".
	if ( 1 !== $facet['id'] ) {
		return $row;
	}

	// We change the date format to match date facet format (Y-m-d or Y-m-d h:i:s).
	$row['facet_value'] = date( 'Y-m-d', strtotime( $row['facet_value'] ) );
	$row['facet_name']  = $row['facet_value'];

	// Return row to insert in the index table.
	return $row;

}
add_filter( 'wp_grid_builder/indexer/row', 'prefix_row_data', 10, 3 );