{"id":1993,"date":"2009-05-20T19:50:49","date_gmt":"2009-05-20T16:50:49","guid":{"rendered":"http:\/\/mummila.net\/nuudelisoppa\/?p=1993"},"modified":"2009-05-20T19:50:49","modified_gmt":"2009-05-20T16:50:49","slug":"how-to-separate-every-other-comment-within-a-wp_list_comments-callback-function","status":"publish","type":"post","link":"https:\/\/mummila.net\/nuudelisoppa\/2009\/05\/20\/how-to-separate-every-other-comment-within-a-wp_list_comments-callback-function\/","title":{"rendered":"How to separate every other comment within a wp_list_comments callback function"},"content":{"rendered":"<p>Just upgraded one of my themes (the only one I&#8217;m still using that I can truly say I&#8217;ve created myself) to finally utilize <a href=\"http:\/\/codex.wordpress.org\/Template_Tags\/wp_list_comments\">WordPress 2.7&#8217;s new comment listing function<\/a>. This made <a href=\"http:\/\/sivel.net\/2008\/10\/wp-27-comment-separation\/\">separating actual comments from pings<\/a> a breeze compared to what it used to be.<\/p>\n<p>The only slight problem was with porting the old separation of every other comment with a different class; since I needed to use a custom callback to retain the old look, I couldn&#8217;t utilize the automated classification done by <code>wp_list_comments()<\/code>. In the end all it took was these three lines added to my callback function:<\/p>\n<blockquote>\n<pre><code>global $comment_alt;\n$oddcomment = $comment_alt % 2 ? 'alt' : '';\n$comment_alt++;<\/code><\/pre>\n<\/blockquote>\n<p>With these in place I could now bring in the &lt;li&gt; tag from the old template without any further tweaking:<\/p>\n<blockquote>\n<pre><code>&lt;li id=\"comment-&lt;?php comment_ID() ?&gt;\"\nclass=\"&lt;?php echo $oddcomment?&gt;\"&gt;<\/code><\/pre>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Just upgraded one of my themes (the only one I&#8217;m still using that I can truly say I&#8217;ve created myself) to finally utilize WordPress 2.7&#8217;s new comment listing function. This made separating actual comments from pings a breeze compared to what it used to be. The only slight problem was with porting the old separation [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[9387,26],"class_list":["post-1993","post","type-post","status-publish","format-standard","hentry","tag-blog","tag-open-source"],"_links":{"self":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts\/1993","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/comments?post=1993"}],"version-history":[{"count":0,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts\/1993\/revisions"}],"wp:attachment":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/media?parent=1993"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/categories?post=1993"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/tags?post=1993"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}