wp_html_excerpt() – Safely extracts not more than the first $count characters from html string.
You appear to be a bot. Output may be restricted
Description
Safely extracts not more than the first $count characters from HTML string.
UTF-8, tags and entities safe prefix extraction. Entities inside will NOT be counted as one character. For example & will be counted as 4, < as
- , etc.
- $str
- ( string ) required – String to get the excerpt from.
- $count
- ( int ) required – Maximum number of characters to take.
- $more
- ( string ) optional – Optional. What to append if $str needs to be trimmed. Defaults to empty string.
Usage
$string = wp_html_excerpt( $str, $count, $more );
Parameters
Returns
string The excerpt.
Source
File name: wordpress/wp-includes/formatting.php
Lines:
1 to 16 of 16
function wp_html_excerpt( $str, $count, $more = null ) { if ( null === $more ) { $more = ''; } $str = wp_strip_all_tags( $str, true ); $excerpt = mb_substr( $str, 0, $count ); // Remove part of an entity at the end. $excerpt = preg_replace( '/&[^;\s]{0,6}$/', '', $excerpt ); if ( $str != $excerpt ) { $excerpt = trim( $excerpt ) . $more; } return $excerpt; }