Codex tools: Log in
Safely extracts not more than the first $count characters from an HTML string.
This function performs UTF-8-, tags- and entities-safe excerpt extraction. Entities inside will not be counted as one character. For example & will be counted as 4, < as 3, etc.
<?php wp_html_excerpt( $str, $count, $more ); ?>
<?php $str = 'There are lots & <strong>lots</strong> of usages for this function. I know you can think of some! (lots more text here)'; echo wp_html_excerpt( $str, 50 ); // Output: 'There are lots & lots of usages for this funct' // Using the $more parameter: echo wp_html_excerpt( $str, 50, '...' ); // Output: 'There are lots & lots of usages for this funct...' ?>
wp_html_excerpt() is located in