WordPress Ad Code Skills

Sometimes we want our ads codes show differently at our wordpress blog. Say we want to show adsense codes different types at different place, say homepage, single post. Simple!

The following code will show your ad code one at single post and single page, and ad code two at other places:

<div>
 <?php if (is_single() or is_page()) : ?>
<div style=”float:right;margin-left:40px”>
ad code one
</div>
<?php elseif ($wp_query->current_post == 0) : ?>
<div style=”float:right;margin-left:40px”>
ad code two
</div>
<?php endif; $postcnt++; ?>

more useful code for wordpress:

<div>
 <?php if (is_single() or is_page()) : ?>
<div style=”float:left;margin-right:60px”><br>
ad code one
</div>
<?php elseif ($wp_query->current_post == 0) : ?>
<div style=”float:left;margin-right:60px”><br>
ad code two
</div>
<div>
<?php endif; $postcnt++; ?>

More related useful wordpress tags such as is_category(), is_home() at http://codex.wordpress.org/Conditional_Tags#The_Main_Page.

King Php Science Welcome, you are from: 54.198.143.223