Use this shortcode to display a specific post’s comment count. All you have to do is add the post ID.
PHP
Usage: [comments id="1"]
<?php function comments_shortcode($atts) { extract( shortcode_atts( array( 'id' => '' ), $atts ) ); $num = 0; $post_id = $id; $queried_post = get_post($post_id); $cc = $queried_post->comment_count; if( $cc == $num || $cc > 1 ) : $cc = $cc.' Comments'; else : $cc = $cc.' Comment'; endif; $permalink = get_permalink($post_id); return '<a href="'. $permalink . '" class="comments_link">' . $cc . '</a>'; } add_shortcode('comments', 'comments_shortcode'); ?>
Comments will be moderated and
rel="nofollow"
will be added to all links. You can wrap your coding with[code][/code]
to make use of built-in syntax highlighter.