Skip Navigation

[Resolved] Product description and short description without line breaks

This support ticket is created 2 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 9 replies, has 2 voices.

Last updated by Waqar 2 years, 2 months ago.

Assisted by: Waqar.

Author
Posts
#2473933
Screenshot from 2022-10-11 10-40-14.png
Screenshot from 2022-10-11 10-42-08.png

I am trying to: Just print product information for using toolset

Link to a page where the issue can be seen: hidden link

I expected to see: Short description and description with line breaks

Instead, I got: Text without line breaks

#2473953

Hello,

i have another development site and same issue. Astra Pro theme without any custom code.

hidden link

br. Keijo

#2474075

Hi Keijo,

Thank you for contacting us and I'd be happy to assist.

To troubleshoot and reproduce this on a test website, I'll need to see how this single product template is set up in the admin area.

Can you please share the temporary admin login details of this development website?

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

regards,
Waqar

#2474765

Thank you for sharing these details.

During testing on my website, I was able to reproduce this behavior too. The 'Product Tabs' block is not applying the auto paragraphs to the product content/body.

I've shared these findings with the concerned team for further review. For now, you can use the following workaround code, to make this work:


add_filter( 'the_content', 'filter_the_content_in_the_main_product_loop', 1 );
function filter_the_content_in_the_main_product_loop( $content ) {

	// Check if we're inside the main loop in a single product.
	if ( is_singular('product') && in_the_loop() && is_main_query() ) {
		$content = '[wpv-autop]'.$content.'[/wpv-autop]';
	}

	return $content;
}

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.

#2475293
Screenshot from 2022-10-13 11-22-09.png

Hello,

Thanks for fast reply!

This solution will work with a field named "Description", but the "Short Description" field still has the same problem.

See attachment.

Br. Keijo

#2476177

Thanks for the update.

For the shortcode description, WooCommerce uses the WordPress excerpts feature, which usually shows the text, without any auto paragraphs or formatting.

To make the automatic paragraphing work for the short product description field, you can include the following custom code:


function filter_the_excerpt_in_the_main_product_loop( $excerpt ) {
	if ( is_admin() ) {
		return $excerpt;
	}

	if ( is_singular('product') ) {
		$excerpt = '[wpv-autop]'.$excerpt.'[/wpv-autop]';
	}

	return $excerpt;
}
add_filter( 'get_the_excerpt', 'filter_the_excerpt_in_the_main_product_loop', 999 );

Next, replace the Toolset's "Single Field" block with WordPress' "Post Excerpt" block in the template to show this short description.

#2477467
Screenshot from 2022-10-17 11-09-14.png

Hello,

Short description is still without line breaks.

Br. Keijo

#2478125

Looks like you missed the last step.

> Next, replace the Toolset's "Single Field" block with WordPress' "Post Excerpt" block in the template to show this short description.

I've included a "Post Excerpt" ( screenshot: hidden link ) block in the template and it is showing the excerpt with the line breaks ( screenshot: hidden link )

#2479023

Hello,

Thanks! All good now.

Will your team fix this issue in the next Toolset update?

Br. Keijo

#2479789

Glad that it worked.

It won't be possible to share any time estimate for the 'Product Tabs' block's issue, but we've published an erratum for it, with a more precise custom code:
https://toolset.com/errata/paragraphs-and-line-breaks-missing-from-product-description-when-using-product-tabs-block/

As for the excerpts, they are generally expected to show as plain text. So for anyone looking to show them formatted, the custom code can be used, on a case-to-case basis.