Referring to Adding vendor links to the listing block footer - #12 by ihor
The solution given by kaykelly88 was perfectly locate the vendor name at the footer of the primary attributes. How to modified this code so that the vendor name will relocated at the secondary attribute instead?
add_filter(
'hivepress/v1/templates/listing_view_block/blocks',
function ($blocks, $template){
$listing = $template->get_context('listing');
if(!$listing){
return $blocks;
}
$vendor_id = $listing->get_vendor__id();
if(!$vendor_id){
return $blocks;
}
return hivepress()->helper->merge_trees(
[ 'blocks' => $blocks ],
[
'blocks' => [
'listing_actions_primary' => [
'blocks' => [
'listing_vendor_link' => [
'type' => 'content',
'content' => '<a href="'.esc_url( hivepress()->router->get_url( 'vendor_view_page', [ 'vendor_id' => $vendor_id ] ) ).'"><p><strong>'.esc_html($listing->get_vendor__name()).'</strong></p></a>',
'_order' => 30,
],
],
],
],
]
)['blocks'];
},
1000,
2
);
andrii
January 19, 2024, 2:49pm
4
Hi,
Please try to change the primary
to secondary
in the code, then everything should be displayed in the secondary block.
did you mean like this? It’s still doesn’t work
add_filter(
'hivepress/v1/templates/listing_view_block/blocks',
function ($blocks, $template){
$listing = $template->get_context('listing');
if(!$listing){
return $blocks;
}
$vendor_id = $listing->get_vendor__id();
if(!$vendor_id){
return $blocks;
}
return hivepress()->helper->merge_trees(
[ 'blocks' => $blocks ],
[
'blocks' => [
'listing_actions_secondary' => [
'blocks' => [
'listing_vendor_link' => [
'type' => 'content',
'content' => '<a href="'.esc_url( hivepress()->router->get_url( 'vendor_view_page', [ 'vendor_id' => $vendor_id ] ) ).'"><p><strong>'.esc_html($listing->get_vendor__name()).'</strong></p></a>',
'_order' => 30,
],
],
],
],
]
)['blocks'];
},
1000,
2
);
andrii
January 23, 2024, 8:41am
9
Hi,
I see. Please also try listing_attributes_secondary
, if it doesn’t work, then check out the code in more detail here hivepress/includes/templates/class-listing-view-block.php at master · hivepress/hivepress · GitHub .
system
Closed
February 22, 2024, 8:41am
10
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.