Returns a comment link with a comment icon. You must have a comment icon that is called comments for that part to work.
Parameters
$comment_string: (boolean) If true, it will return some text along with the number of comments. Based on how many comments there are, it will return either, ‘No Comments’, ‘1 Comment’, or ‘x Comments’, where x is the number of comments.
By default this is false and only a number is output.$
File: inc/template-tags.php
function ign_comment_link( $comment_string = false ) {
$num_comments = get_comments_number(); // get_comments_number returns only a numeric value
if ( comments_open() ) {
if ( $num_comments == 0 ) {
$num_comments = '';
$comments = __( 'No Comments' );
} elseif ( $num_comments > 1 ) {
$comments = $num_comments . __( ' Comments' );
} else {
$comments = __( '1 Comment' );
}
if ( $comment_string ) {
$write_comments = '<a class="comment-link" href="' . get_comments_link() . '"><span
class="screen-reader-text">Comments</span>' . ign_get_svg( array(
'icon' => 'comments'
) ) . ' ' . $comments . '</a>';
} else {
$write_comments = '<a class="comment-link" href="' . get_comments_link() . '"><span
class="screen-reader-text">Comments</span>' . ign_get_svg( array(
'icon' => 'comments'
) ) . ' ' . $num_comments . '</a>';
}
return $write_comments;
}
return;
}