Update: Apparently this code is also necessary when you want to list the comments on the blog page, and probably on archive pages as well. There could be a better solution, if you really care check out the P2 theme (and leave a comment).
Sometimes you want to access WordPress content outside of WordPress. There are various pages that explain how to this and it's really easy to do as well. What I tried to do was a little different though, I wanted to print comments outside of WordPress.
To my surprise
wp_list_comments() didn't output anything inside my custom loop. It turned out that
NULL, which I think is rather odd. I would have expected it to be defined like in a normal loop inside WordPress. However, the fix is trivial:
<?php global $post, $wp_query; $args = array( 'ID' => $post->ID, 'status' => 'approve', 'order' => 'ASC' ); $wp_query->comments = get_comments( $args ); wp_list_comments( ); comment_form(); }?>
comment_form()is a WordPress 3.0 feature by the way, so you may not want to use it yet.