WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using this to allow me to display my comments for posts on category pages:

$wp_query->is_single = true;
$wp_query->is_single = false;

However I don't want to display the comment form. Is there a way to display the comments only on a comment page?

share|improve this question
up vote 1 down vote accepted

Use get_comments() and pass the post ID as parameter. Then print the result as regular list. From a plugin I have published recently:

function t5_list_comments( $atts, $content = '' )
    '' !== $content && $content = wpautop( do_shortcode( $content ) );

    if ( ! isset ( $atts['post_id'] ) )
        return 'Please pass an argument for "post_id"';

    if ( ! $comments = get_comments( $atts ) )
        return 'No comments found for post ID '. esc_html( $atts['post_id'] );

    $out = $content . '<ul class="t5-comment-list">';
    foreach ( $comments as $comment )
        $out .= sprintf(
            '<li>%1$s - %2$s %3$s</li>',
            get_comment_author_link( $comment->comment_ID ),
            get_comment_date( 'd.m.Y H:i', $comment->comment_ID ),
            wpautop( $comment->comment_content )

    return $out . '</ul>';

You can use it like this:

print t5_list_comments( array ( 'post_id' => get_the_ID() ) );
share|improve this answer
this works great, just can't figure out how to format the comment date using wpautop( $comment->comment_date). Any idea? – JonnyPlow Jan 15 '13 at 21:09
@JonnyPlow See my update. – toscho Jan 15 '13 at 21:25
thanks a bunch, works wonders! – JonnyPlow Jan 15 '13 at 21:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.