Hi... I want to show adsense ads only on those posts and pages which are written in the year 2011. It there any way of doing it in wordpress ?
Hi... I want to show adsense ads only on those posts and pages which are written in the year 2011. It there any way of doing it in wordpress ?
use a conditional statement in the loop;
example:
<?php if( get_the_time('Y') == 2011 ) { ?>
/*ADS CODE HERE*/
<?php } ?>
How can I do it outside the loop ?
from: http://codex.wordpress.org/Function_Reference/get_the_time
Returns the time of the post with ID $post->ID in the WordPress default format.
<?php echo get_the_time('', $post->ID); ?>
details will depend on how you included the adsense in the first place;
and it will only make sense on a single post page; example:
<?php if( is_single() && get_the_time('Y', $post->ID) == 2011 ) { ?>
/*ADS CODE HERE*/
<?php } ?>thanks it works now :)
This topic has been closed to new replies.