Display category on vendor's profile

I came across this site and the category for each vendor displayed here:

How do I make each category chosen by a vendor to display here:

  1. How do I add regions or states to in my location bar

Thanks :pray:t2:

1 Like
  1. Please try this PHP snippet but please note that it can require further customization
add_filter(
	'hivepress/v1/templates/vendor_view_block/blocks',
	function($blocks, $template){
		$vendor = $template->get_context('vendor');
		
		if(!$vendor || !$vendor->get_categories()){
			return $blocks;
		}
		
		$output = '';
		
		foreach ( $vendor->get_categories() as $category ){
			$output .= '<span>'.esc_html( $category->get_name() ).'</span>';
		}
	
		return hivepress()->helper->merge_trees(
			[ 'blocks' => $blocks ],
			[
				'blocks' => [
					'vendor_content' => [
						'blocks' => [
							'custom_vendor_categories' => [
								'type'   => 'content',
								'content'  => $output,
								'_order' => 21,
							],
						],
					],
				],
			]
		)['blocks'];
	},
	1000,
	2
);
  1. Please provide more details about this issue. By default location field searches by any address if there is no restriction in countries
1 Like

This is an improvement that I think is a must. I have tested the code snippet and it shows the category but it shows it not centered, i.e. shifted to the left.
Do you know how to fix this?
And I suggest that you include it in new revisions because I think other users will find this information useful.
Thank you very much for the good work you do.

Es una mejora que considero que es imprescindible. He probado el fragmento de código y muestra la categoría pero la muestra no centrada, es decir, desplazada a la izquierda.
Saben como solucionar esto?
Y sugiero que lo incluyan en las nuevas revisiones porque pienso que a los demás usuarios les resultara útil esa información.
muchas gracias por el buen trabajo que haces.

Thanks for your suggestion, we’ll check the possibility to add this feature

Please try this CSS to align categories to the center but please note that it can require further customization

.hp-vendor--view-block .hp-vendor__content{
	text-align: center;
}
1 Like

Snippet works everywhere but on the vendor summary block/page.

I had to customize this feature through a childtheme.

1 Like

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