Show 2 or 3 lines of description in blocks with click feature

Regarding below snippet, now 2 or 3 lines of description is showing in blocks but I need when users click on this description line text it’s clickable and user redirected to the list.

Also in the end of line show this …
It means more …

	function ($blocks, $template){
		$listing = $template->get_context('listing');
		if($listing && $listing->get_description()){
			$description = $listing->get_description();
			if ( strlen( $description ) > 240) {
				$description = substr( $description, 0, 240 ).'...';
			$blocks = hivepress()->helper->merge_trees(
					[ 'blocks' => $blocks ],
						'blocks' => [
							'listing_content' => [
								'blocks' => [
									'custom_listing_description' => [
										'type' => 'content',
										'content' => '<p>'.$description.'</p>',
										'_order' => 1000,
		return $blocks;

Sorry, there’s no simple code snippet - this requires advanced customizations.

If customizations are required for your site, please try customizing it using the collection of code snippets Search · user:hivepress · GitHub and other developer resources, or consider hiring someone for custom work

Thanks, is it possible to just add this text with link “click for more…” and users go to current list details.

Yes, but this requires further customizations. It may be possible to limit the number of rows with a CSS similar to this one Cropping description for listing category blocks showing in the home page - #4 by yevhen with “…” at the end, then users can click the listing title or image to view the listing page.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.