Skip Navigation

[Resolved] Post Excerpt strips HTML

This support ticket is created 6 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 6 years, 2 months ago.

Assisted by: Christian Cox.

Author
Posts
#1185343

Hi, I've set up a view and it's stripping the HTML out of the Post Excerpt.

I've tried using the following fix in my functions.php but it hasn't worked and I'm not sure why? https://toolset.com/forums/topic/views-strip-out-html-markup-form-excerpt/

child theme functions.php hidden link

Excerpt which is being stripped out:
hidden link
hidden link

Thanks

#1185365

It's actually not a trivial thing, because of how character and word counts must be calculated when HTML tags are allowed in the contents. This customer's snippet worked up until quite recently, but I'm not surprised it doesn't work anymore. If you do a web search, you'll find there are tons of other posts out there that offer different custom code to try to make it work. You will see they are all slightly different and function more or less to different degrees. The short answer is HTML in the excerpt is not supported in Toolset or in WordPress, and we don't offer a shortcode or code snippet that provides that capability. Instead, you can use a WYSIWYG custom field if you want to support HTML, and use a Types field shortcode to insert the contents of that excerpt in a template. Let me know if you need assistance implementing a WYSIWYG field instead of the post excerpt.

#1185445

Thanks for the quick answer. Yes I think it would be easier to move away from the post excerpt. Would you be able to point me to instructions on how to set up a Types Field Shortcode and a WYSIWYG custom field?

#1186019

Sure, you can start here to see more about adding custom fields to the post editor screen: https://toolset.com/documentation/user-guides/using-custom-fields/

Then this page describes the shortcodes you can use to insert those custom fields in a template: https://toolset.com/documentation/customizing-sites-using-php/functions/

Click the orange "+More" link in any field type to display more examples. You don't have to write these shortcodes by hand, the system can generate them for you. Place your cursor in a post content or content template editor and click "Fields and Views" above the editor. You can select your custom field here and choose a few options. Then the system will insert the corresponding shortcode, automatically.