Can I add the host's profile photo as a thumbnail on a listing card?

Here’s my website.

I’d love to add a small image of a host’s (AKA “private chef” on my website) on a listing card (AKA “menu” on my website).

Here’s another website that uses this feature for reference.

Hi,

Unfortunately, there’s no such feature, it would require a custom implementation.

Also, you can do this without additional customizations in the TaskHive theme.

Hi Andrii,

Using the below code snippet, I can get the host’s name to the listing block. How come it does not work with get_vendor_image ? Thanks

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
);

You can try using it this way:

$listing->get_vendor__image();

You’ll get an Attachment object or null, and then you can get it’s URL via the ->get_url() method.

1 Like

@aqmiami7 – your code worked to pull the vendor name, thank you!!

Now, how do I use @ihor’s suggestion to pull the vendor image? Could you please modify @aqmiami7’s code if it worked?

If you have a listing object, please try this code to get the URL:

$vendor=$listing->get_vendor();
$url=$vendor->get_image__url('thumbnail');