Last active
November 2, 2021 09:07
Star
You must be signed in to star a gist
An example of using the decent_comments_comment_output filter to customize output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// | |
// An example filter implementation provided in response to this question on the Decent Comments plugin for WordPress | |
// | |
// https://wordpress.org/plugins/decent-comments/ | |
// | |
// https://www.itthinx.com/plugins/decent-comments/comment-page-3/#comment-1127674 | |
// | |
function my_decent_comments_comment_output( $output, $comment_ID, $options ) { | |
$comment = get_comment( $comment_ID ); | |
if ( $comment instanceof WP_Comment ) { | |
$n = get_comments_number( $comment->comment_post_ID ); | |
$output .= '<div class="comments-count">'; | |
$output .= sprintf( _n( | |
'There is one comment on this post.', | |
'There are %d comments on this post.', | |
$n | |
) ); | |
$output .= '</div>'; | |
} | |
return $output; | |
} | |
add_filter( 'decent_comments_comment_output', 'my_decent_comments_comment_output', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment