How to call the_excerpt() with tags or the_content() as an excerpt?

Actually, I just did something like this for a Drupal site. I based my truncation function on this: Truncate text preserving HTML tags with PHP

Use the final version of the function at the end of the comments. The function takes its $length parameter in characters, not words, but you can probably use the general rule-of-thumb of 5 characters per word to estimate, if needed.

Hook your function to the get_the_excerpt filter, and you should be in pretty good shape.

Leave a Comment