Could you please share with me a snippet to display a vendor attribute in the listing block?
I wrote like bellow code.
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
);
So I can became display categories.
And I want to display vendor’s attribute too.
How do I write code?
Please teach me.