I’m getting ready to submit a theme to the .Org repo and wanted to make sure that everything is in ordnung. One of the biggest holes left in my design is the comments template.
I’ve taken a look at comments.php in a few themes, Twenty Ten chief among them and have come away more confused than when I started. It seems as though (based upon tutorials from Otto, WP Engineer, etc.) the comments template has been simplified, yet when I look at the source to most themes’ comments.php, they are still as convoluted as in the Christian-Montoya-derived days of old.
So help me out — what’s the best way to set up a comments template that will capture the state-of-the art functionality as of WP 3.0/3.1 and yet maintain code simplicity?
You really donât need much.
A headline with id=comments
This will be the target for
comments_link()
in the article loop.Links for paginated comments.
Usually, I put these links into a function and call the function above and below the comments list:
wp_list_comments()
You may use a custom callback function, but you donât have to. For a theme on wp.org Iâd use gravatars in the callback. And I wouldnât namespace it with
my_
. 😉As you can see, the
type
parameter allows you to separate normal comments from pings. See the codex for more information. If you build two separate lists, checkget_option( 'default_ping_status' );
to avoid an empty list.comment_form();
You may use the default settings or add your own filters. I use a custom class to move the textarea to top and rearrange some minor other things.
And thatâs all.
Complete code
Use Disqus