Skip to content

Commit

Permalink
Trim the Discourse comment body to 50 words
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffguillain committed Sep 26, 2024
1 parent dac9391 commit e490203
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions themes/osi/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,3 +407,15 @@ function osi_adjust_offset_pagination( int $found_posts, WP_Query $query ) {
return $found_posts;
}
add_filter( 'found_posts', 'osi_adjust_offset_pagination', 1, 2 );

/**
* Trim the Discourse comment body to 50 words.
*
* @param string $comment_body
* @return void
*/
function osi_wpdc_comment_body( $comment_body ) {
$trimmed_comment_body = wp_trim_words( $comment_body, 50, '(...)' );
return $trimmed_comment_body;
}
add_filter( 'wpdc_comment_body', 'osi_wpdc_comment_body', 10, 1 );

0 comments on commit e490203

Please sign in to comment.