Yes, but this depends on how these HTML parts are added to the vendor template, have you inserted them via the template filter hooks? If listing or vendor objects are available in the template context then the snippets you suggested should be ok.
I tried adding them via filter hooks in some template parts I already created and they work fine, but I’m not sure on how to add the desired class to the listing container.
Or at least I don’t know how to use the filter hook with my if statement as the variables are not available in the functions.php directly.
Thank you Yevhen, I know how to add custom classes this way, that is not my main problem. The problem is how to include the if statement, I mentioned above, in your snippet. Or in detail, how to check, if the vendor has a specific attribute set before adding the class to the listing container.
Please try this PHP snippet as an example of how to get a vendor attribute in the listing template and use it as a condition
add_filter(
'hivepress/v1/templates/listing_view_block/blocks',
function($blocks, $template){
// Get listing.
$listing = $template->get_context('listing');
if(!$listing){
return $blocks;
}
// Get vendor.
$vendor = $listing->get_vendor();
if(!$vendor){
return $blocks;
}
if($vendor->get_your_attribute_field()){
// if vendor has some attribute value.
}else{
// if vendor does not have some attribute value.
}
return $blocks;
},
1000
);