Created
May 13, 2018 13:50
-
-
Save mdjwel/7d8bfcfb09ab54de61ea4698e4b81ab2 to your computer and use it in GitHub Desktop.
Get the post comment count text based the comments have in a WordPress post loop.
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 | |
// Get comment count text | |
function prefix_comment_count($post_id) { | |
$comments_number = get_comments_number($post_id); | |
if($comments_number==0) { | |
$comment_text = esc_html__('No comment', 'chaoz'); | |
}elseif($comments_number == 1) { | |
$comment_text = esc_html__('One comment', 'chaoz'); | |
}elseif($comments_number > 1) { | |
$comment_text = $comments_number.esc_html__(' Comments', 'chaoz'); | |
} | |
echo esc_html($comment_text); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment