The Movable Type Knowledge Base

MTEntryExcerpt Does Not Include HTML

Question

When I use the <MTEntryExcerpt> tag to display the excerpt for my entry, the HTML is removed from the text.

Answer

The behavior of the <MTEntryExcerpt> tag differs depending on whether or not you have entered your own text in the Excerpt field on the Edit Entry screen.

If you do not enter your own excerpt for the entry, Movable Type will automatically generate one for you based on the Entry Body and your specified Excerpt Length setting in Settings > General : Default Weblog Display Settings1. This is the equivalent of using the following tag:

<MTEntries words="N">

where N is the number of words you've specified for the setting. To find the first N words, HTML is first removed from the entry body, then the body split on whitespace. Otherwise, the word count could end in the middle of an HTML tag, resulting in broken code on your page.

If you wish for HTML to appear in your excerpts, you will need to use the Excerpt field to enter your own excerpt and include the HTML you wish to use. This will override the auto-generated excerpt and permit the HTML to appear when the <MTEntryExcerpt> tag is used.

1 In versions prior to 3.2, navigate to Weblog Configuration > Preferences and look for the Number of Words in Excerpt setting.

Submit Feedback on This Article

Your comments on how we can improve this article are appreciated; but please do not use the feedback form to submit support requests or questions. We will not respond to or publish such queries submitted through this form. If you have a technical question or problem, visit Movable Type Support.

Yahoo! Small Business web hosting services

Six Apart
Makers of weblog software and services for individuals, organizations and businesses.
This website is powered by Movable Type.