Change sidebar classes

Hello.
I need to replace sidebar classes.
This snippet add extra classes to < aside > element.

add_filter(
	'hivepress/v1/templates/page_sidebar_left',
	function( $template ) {
		return hivepress()->helper->merge_trees(
			$template,
			[
				'blocks' => [
					'page_sidebar' => [
						'attributes' => [
							'class' => [ 'hp-page__sidebar', 'hp-col-sm-3', 'hp-col-xs-12' ],
						],
					],
				],
			]
		);
	}
);

And also I need replace css in block with listings to ‘hp-page__content hp-col-sm-9 hp-col-xs-12’.

How I can replace css list completly?

Thanks.

Unfortunately, there is no simple snippet to change classes, it requires advanced customization. But it is possible to add additional classes and then add !important flag !important - CSS: Cascading Style Sheets | MDN to CSS properties to override the old one

Thanks, but I think this is not a good solution.

Please try this PHP snippet but please note that it can require further customization

add_filter(
	'hivepress/v1/templates/page_sidebar_left',
	function( $template ) {
		$block = hivepress()->template->fetch_block($template, 'page_sidebar');
		
		if(!$block){
			return $template;
		}
			
		// Set new classes.
		$block['attributes']['class'] = [ 'hp-page__sidebar', 'hp-col-sm-3', 'hp-col-xs-12' ];
		
		return hivepress()->helper->merge_trees(
			$template,
			[
				'blocks' => [
					'page_columns' => [
						'blocks' => [
							'page_sidebar' => $block,
						],		
					],
				],
			],
		);
	},
	1000
);

Thank you.
This snippet works.

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