get_comment_excerpt()
Gets a trimmed version of the current or specified comment (maximum 20 words).
If the text was trimmed, … will be added at the end.
The output is not processed by the function wpautop().
Used By: comment_excerpt()
1 time — 0.000609 sec (slow) | 50000 times — 5 sec (fast)
Hooks from the function
Returns
String. Trimmed/untrimmed text.
Usage
get_comment_excerpt( $comment_ID );
- $comment_ID(int/WP_Comment) (required)
- ID or comment object to check for length, and if necessary, trim.
Default: 0 (current comment in the loop)
Examples
#1 Cut the text of the comment to 20 words, if it is more.
echo get_comment_excerpt( 1024 ); // output: // Looked at Get Recent Comments - messed up a mountain of code :) Tested my code queries creates a standard function of WordPress..
Changelog
| Since 1.5.0 | Introduced. |
| Since 4.4.0 | Added the ability for $comment_id to also accept a WP_Comment object. |