How to change background of categories


i tried to make some changes in categories background but the problem i have i cant find the diffrent like ID to target each one on its own what i need to do can someone help?

Hi,

Yes, this version does not have unique category classes, but we plan to add them in future updates. As a workaround, you can use CSS nth-child or we can provide a PHP snippet to add a unique class for the category.

do you have the snippet or you still working on it

Please try this one, it should add unique CSS class to each category like .hp-listing-category-123:

add_filter(
	'hivepress/v1/templates/listing_category_view_block/blocks',
	function( $blocks, $template ) {
		$category = $template->get_context( 'listing_category' );

		return hivepress()->template->merge_blocks(
			$blocks,
			[
				'listing_category_container' => [
					'attributes' => [
						'class' => [ 'hp-listing-category-' . $category->get_id() ],
					],
				],
			],
		);
	},
	1000,
	2
);
1 Like


yes it indeed worked now each category have a unique ID thanks bro i appreciate you :ok_hand::wink:

1 Like