{"id":29,"date":"2005-01-12T11:12:22","date_gmt":"2005-01-12T16:12:22","guid":{"rendered":"http:\/\/lee.org\/blog\/archives\/2005\/01\/12\/alternating-colors-for-posts-hack\/"},"modified":"2005-04-01T01:12:09","modified_gmt":"2005-04-01T06:12:09","slug":"alternating-colors-for-posts-hack","status":"publish","type":"post","link":"https:\/\/www.lee.org\/blog\/2005\/01\/12\/alternating-colors-for-posts-hack\/","title":{"rendered":"Alternating Colors for Posts Hack"},"content":{"rendered":"<p>This hack was originally made for WP version 1.2. It works with 1.5 though the line numbers mentioned are a little different.<\/p>\n<p>This is a derivative of the Alternating Colors for Comments change<\/p>\n<p>In Index.php, add what&#8217;s in red in line 34 like so:<br \/>\n<code>&lt;?php if ($posts) :<font color=\"#FF0000\">$i=0;<\/font> foreach ($posts as $post) : start_wp(); ?&gt;<\/code><\/p>\n<p>Replace line 40:<br \/>\n<code>&lt;div class=&quot;post&quot;&gt;<\/code><br \/>\nwith the following:<br \/>\n<code>&lt;?php if($i%2) {echo &quot;&lt;div class=&quot;post-even&quot;&gt;&quot;;} else {echo &quot;&lt;div class=&quot;post&quot;&gt;&quot;;} $i++ ?&gt;<\/code> <br \/>\nTo finish it off, add a class in wp-layout.css like so:<br \/>\n<code>.post-even { background-color: #EEEEEE;}<\/code><\/p>\n<p>\nAnd gosh darn it, I can&#8217;t figure out how to do proper code quoting. The entries<br \/>\nabove do NOT display correctly. The double quotes inside the echos need to be<br \/>\nescaped with a slash just before them. Sorry I can&#8217;t display them properly in<br \/>\nWordpress!<br \/>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This hack was originally made for WP version 1.2. It works with 1.5 though the line numbers mentioned are a little different. This is a derivative of the Alternating Colors for Comments change In Index.php, add what&#8217;s in red in line 34 like so: &lt;?php if ($posts) :$i=0; foreach ($posts as $post) : start_wp(); ?&gt; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-29","post","type-post","status-publish","format-standard","hentry","category-wordpress"],"_links":{"self":[{"href":"https:\/\/www.lee.org\/blog\/wp-json\/wp\/v2\/posts\/29","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lee.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lee.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lee.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lee.org\/blog\/wp-json\/wp\/v2\/comments?post=29"}],"version-history":[{"count":0,"href":"https:\/\/www.lee.org\/blog\/wp-json\/wp\/v2\/posts\/29\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.lee.org\/blog\/wp-json\/wp\/v2\/media?parent=29"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lee.org\/blog\/wp-json\/wp\/v2\/categories?post=29"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lee.org\/blog\/wp-json\/wp\/v2\/tags?post=29"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}