Add custom CSS class to the HivePress Listing View block

Hi,

I am trying to add a custom CSS class to each listing view block on the Listings view page. So far I have been able to add a custom CSS class to the main div (that contains all listings) using the below code

add_filter(
	'hivepress/v1/blocks/listing-categories',
	function( $args ) {
		return hivepress()->helper->merge_arrays(
			$args,
			[
				'attributes' => [
					'class' => [ 'gridbox' ],
				],
			]
		);
	}
);

However, I am not able to add a custom CSS class similarly to the each listing div. Can anyone help me out on this?

Thanks.

Hi,

Please try this PHP snippet:

add_filter(
	'hivepress/v1/templates/listing_view_block',
	function($template){
		return hivepress()->template->merge_blocks(
			$template,
			[
				'listing_container' => [
					'attributes' => [
						'class' => ['test-custom-class'],
					],
				],
			],
		);
	},
	1000
);
1 Like

Thank you so much!! Exactly what I needed.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.