Skip to content

Commit e490203

Browse files
committed
Trim the Discourse comment body to 50 words
1 parent dac9391 commit e490203

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

themes/osi/functions.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,3 +407,15 @@ function osi_adjust_offset_pagination( int $found_posts, WP_Query $query ) {
407407
return $found_posts;
408408
}
409409
add_filter( 'found_posts', 'osi_adjust_offset_pagination', 1, 2 );
410+
411+
/**
412+
* Trim the Discourse comment body to 50 words.
413+
*
414+
* @param string $comment_body
415+
* @return void
416+
*/
417+
function osi_wpdc_comment_body( $comment_body ) {
418+
$trimmed_comment_body = wp_trim_words( $comment_body, 50, '(...)' );
419+
return $trimmed_comment_body;
420+
}
421+
add_filter( 'wpdc_comment_body', 'osi_wpdc_comment_body', 10, 1 );

0 commit comments

Comments
 (0)