More and more people love to use wordpress to setup blogs and place adsense ads, and many people still love the use the theme of Classic, by Dave Shea. Can we show different adsense code at the same place, but different pages then? For example, we want to show 2 adsense block at the main body of detailed pages, but only show 1 adsense block at other page’s main body.
First, we can use $wp_query->current_post == 0 to check the current post is the first post or not, second, we can use is_single() to check the current page is a detailed post page or not.
We can use if (is_single() AND $wp_query->current_post == 0) to check the current post is the first or not and current page is a detailed post page or not. If the result is true, then show 2 adsense block ads. Otherwise if the current is the first post, then show 1 adsense block.
Here is the code:
<?php if (is_single() AND $wp_query->current_post == 0):
echo (‘ <div style=”float:left;margin-right:60px”>ads 1 <br> ads 2 </div> <div> ‘);
elseif ($wp_query->current_post == 0):
echo (‘ <div style=”float:left;margin-right:60px”> add </div> <div> ‘);
endif; $postcnt++; ?>
codex.wordpress.org/Conditional_Tags
codex.wordpress.org/The_Loop