Gets a trimmed excerpt to display in place of a missing post title.
Description
Only returns text in the Compact list view for posts that have no title, do not require a password, and that the current user is allowed to read.
Parameters
Source
protected function get_no_title_excerpt( $post ) {
global $mode;
if ( 'excerpt' === $mode
|| '' !== get_the_title( $post )
|| post_password_required( $post )
|| ! current_user_can( 'read_post', $post->ID )
) {
return '';
}
$excerpt = get_the_excerpt( $post );
if ( '' === $excerpt || ! is_string( $excerpt ) ) {
return '';
}
return esc_html( wp_trim_words( $excerpt, 15 ) );
}
Changelog
| Version | Description |
|---|---|
| 7.1.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.