Skip to content

Instantly share code, notes, and snippets.

@itthinx
Last active Nov 2, 2021
Embed
What would you like to do?
An example of using the decent_comments_comment_output filter to customize output
<?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