Alternating Your Post Background Colors

May 12, 2008

Here are the steps you need to take: Create a loop counter. Right before the Loop begins set a variable to zero. <?php $x=0; if (have_posts()) : ?> At this point I would want the Background Color to change, insert code to test for an even number post, and if this is true, add an inline CSS style for the background that would override the stylesheet. <?php if ($odd = $x%2){?> <div style=”background-color:#404040;padding:10px 0px 10px 10px;”> <?php }?> Then, where the background color should... [Read the full story]

Display Adsense On Your First Post Within The Loop

May 12, 2008

In this guide you’ll learn how to display Adsense on just your first post within the Loop. Sure, there may be plugins that will do this for you. This guide, however, will use code examples to accomplish the same thing by editing your WordPress theme. The first step is to open up your index.php file in your theme editor. Find the following line: <?php if(have_posts()) : ?> Just above that, insert the following like this: <?php $i = 1; ?> <?php if(have_posts()) : ?> Now, scroll down a bit until you find... [Read the full story]