Tell us what you are trying to do?
I've used a recommended shortcode to truncate a long field in archive display, but one entry includes italics, which I need to clear prior to the next record display.
Is there any documentation that you are following?
No...searched and no easy Toolset solution found.
Is there a similar example that we can see?
For behavior, see hidden link
Further information: see https://toolset.com/forums/topic/truncate-text-field-in-blocks-editor/ for the shortcode I used to truncate a long WYSIWYG field. One person began this field with a quote in italics, hence the truncated extract ends in italics, which is continued on all subsequent records in the archive view.
Perhaps there is something I can add to the shortcode, or as an additional block in the archive loop following the shortcode, to clear this, and possibly other, formatting?
Jim P.
Hi Jim,
Thank you for contacting us and I'd be happy to assist.
The challenge here is that while truncating the long content from the field, we'll not know exactly which HTML tag will be available and at which position specifically its opening and closing tags exist.
The safest and efficient approach, in this case, would be to strip all HTML tags from such content when truncating it, through the "wp_strip_all_tags" function.
( ref: https://developer.wordpress.org/reference/functions/wp_strip_all_tags/ )
For example, assuming you're still using the shortcode from the other support thread ( ref: https://toolset.com/forums/topic/truncate-text-field-in-blocks-editor/#post-1470587 ), line# 3 will change from:
$content = do_shortcode($content);
To:
$content = do_shortcode($content);
$content = wp_strip_all_tags($content);
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
My issue is resolved now. Thank you!