Description and Tags on Listing Block search page

Hello,

I couldn’t add to the existing topic “Add description to listing block” since it’s now closed but I was wondering if it’s possible to display just the 5 first lines and not the entire description. Also, is it possible to add the Tags below it?

Thank you
Philippe

Please try this PHP snippet but please note that it can require further customization

add_filter( 
	'hivepress/v1/templates/listing_view_block/blocks', 
	function( $blocks, $template ) {
		$listing = $template->get_context('listing');
		
		if(!$listing){
			return $blocks;
		}
		
		$description = $listing->get_description();
		
		if (strlen( $description ) > 120 ) {
			$description_parts = explode( ' ', substr( $description, 0, 120 ) );
			$description_parts[ count( $description_parts ) - 1 ] = '...';
			$description = implode( ' ', $description_parts );
		}
		
		$tags = $listing->get_tags();
		$tag_view = [];
		
		foreach((array)$tags as $tag){
			$tag_view[] = $tag->get_name();
		}
	
		return hivepress()->helper->merge_trees(
					[ 'blocks' => $blocks ],
					[
						'blocks' => [
							'listing_content' => [
								'blocks' => [
									'listing_description' => [
										'type'   => 'content',
										'content'  => '<p>'.$description.'</p>',
										'_order' => 40,
									],
									
									'listing_tags' => [
										'type'   => 'content',
										'content'  => implode(', ', $tag_view),
										'_order' => 40,
									],
								],
							],
						],
				]
				)['blocks'];
	
		return $blocks;
	},
	1000,
	2
);

It’s working perfectly, thanks a lot!