Some tips on adding ads code to wordpress

If we do not want ads code shows at wordpress homepage, but at the other pages, we can use the following code:
<?php if (($wp_query->current_post == 0)and (!is_home())) : ?>
<div style=”float:right;margin-left:20px”><br>
Buy sunglasses online.
</div>
<?php endif; $postcnt++; ?>

If we want the ads codes show at all pages, we can use the following codes:
<?php if ($wp_query->current_post == 0) : ?>
<div style=”float:right;margin-left:20px”><br>
Buy sunglasses online.
</div>

<?php endif; $postcnt++; ?>

If we want ads codes show at all pages, at the same time, show another ads codes or the same at the second post in homepage, we can use the folloing code:
<?php if ($wp_query->current_post == 0) : ?>
<div style=”float:right;margin-left:20px”><br>
Buy sunglasses online.
</div>

<?php elseif (($wp_query->current_post == 1)and (is_home())) : ?>
<div style=”float:right;margin-left:20px”><br>
Buy eyeglasses online.
</div>
<?php endif; $postcnt++; ?>

If you only like the ads show at the first post, using the following code:

<?php if ($wp_query->current_post == 0) : ?>
<div style=”float:right;margin-left:20px”><br>
buy glasses online
</div>
<?php endif;?>