Please try this PHP snippet. Please just change [1,2,3]
with categories where you want to show affiliate link
add_filter(
'hivepress/v1/templates/listing_view_page/blocks',
function ($blocks, $template){
$listing = $template->get_context('listing');
$categories_id = [1,2,3];
if($listing && array_intersect((array)$listing->get_categories__id(), $categories_id) ){
$blocks = hivepress()->helper->merge_trees(
[ 'blocks' => $blocks ],
[
'blocks' => [
'listing_actions_primary' => [
'blocks' => [
'message_send_link' => [
'type' => 'content',
],
'custom_affiliate_link' => [
'type' => 'content',
'content' => '<button type="button" class="button button--primary hp-button--wide" data-component="link" data-url="your_url_here">Custom text here</button>',
'_order' => 10,
],
],
],
],
]
)['blocks'];
}
return $blocks;
},
1000,
2
);