Don't added class

Hello!

The class is not added in any way, I have already raised everything, and I have already got from the route to the container, I just can’t understand why the changes are not processed. If I changed something in the plugin and tried hooks, nothing happens.

Example:

add_filter('hivepress/v1/templates/listings_view_page', function ($template){
	return hivepress()->helper->merge_trees($template,[
		'blocks' => [
			'page_container' => [
				'blocks' => [
					'page_columns' => [
						'blocks' => [
							'page_content' =>[
								'blocks' =>[
									'listings_container'=>[
										'attributes' => [
											'class' => 'facetwp-template',
										],
									]
								]
							]
						]
					]
				]
			],
		]
	]);
});

If anything, I’m trying to wrap posts and pagination in one container (although they are already in one in the array) and add a class to it.

To be honest, integrating a custom filter with a plugin is very difficult.
If interested, I can throw off a couple of logical fixes, in the case of facetwp integration.


Привет!:slight_smile:

Никак не добавляется класс, я уже все поднял, уже от роута до контейнера добрался, никак не могу понять почему изменения не отрабатывают. Если что я менял и в плагине и хуками пробовал, ничего не получается.

Пример:

add_filter('hivepress/v1/templates/listings_view_page', function ($template){
	return hivepress()->helper->merge_trees($template,[
		'blocks' => [
			'page_container' => [
				'blocks' => [
					'page_columns' => [
						'blocks' => [
							'page_content' =>[
								'blocks' =>[
									'listings_container'=>[
										'attributes' => [
											'class' => 'facetwp-template',
										],
									]
								]
							]
						]
					]
				]
			],
		]
	]);
});

Если что я пытаюсь обернуть посты и пагинацию в один контейнер(хотя по массиву они и так в одном) и добавить ему класс.

Честно говоря интегрировать кастомный фильтр с плагином очень тяжко.
Если интересно, то могу скинуть пару логических исправлений, в случае интеграции facetwp.

Please try this PHP snippet instead

add_filter(
	'hivepress/v1/templates/listings_view_page', 
	function ($template){
		return hivepress()->helper->merge_trees($template,[
			'blocks' => [
				'listings_container'=>[
					'attributes' => [
						'class' => ['facetwp-template'],
					],
				],
			],
		]);
	},
	1000
);

Also please post in English, this way questions/answers will be useful to others (e.g. use Google Translate to post).

Спасибо за ответ!
К сожалению не помогает(
Мне нужно обернуть посты и пагинацию в один контейнер, по массиву он так и выглядит, а фактичеки они как самостоятельные блоки.


Thanks for the answer!
Unfortunately it doesn’t help(
I need to wrap posts and pagination in one container, it looks like this in an array, but in fact they are like independent blocks.

В общем я отключил шаблон по умолчанию и создал свой архивный шаблон.

Но в итоге я относительно уверен, что похоже баг в плагине, поскольку изменяя массив, он не дает ожидаемого результата.


I turned off the default template and created my archive template.

But in the end, I’m relatively sure that it looks like a bug in the plugin, since changing the array does not give the expected result.

Disabled routing

add_filter('hivepress/v1/routes', function ($routes){
	unset($routes['listings_view_page']);
	return $routes;
});

create new file in theme - archive-hp_listing.php

Please make sure that you correctly put this code snippet with the Code Snippets or the similar plugin

add_filter(
	'hivepress/v1/templates/listings_view_page', 
	function ($template){
		return hivepress()->helper->merge_trees($template,[
			'blocks' => [
				'listings_container'=>[
					'attributes' => [
						'class' => ['facetwp-template'],
					],
				],
			],
		]);
	},
	1000
);

It was tested locally and it seems to be ok

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