-
-
Save srikat/3baf0500abe26b841718 to your computer and use it in GitHub Desktop.
Random ad after every second post in Genesis.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'genesis_after_entry', 'google_ad' ); | |
/** | |
* Insert one random ad after every second post. | |
* | |
* Scope: Posts page and all category archives. | |
* | |
* @author Sridhar Katakam | |
* @link http://sridharkatakam.com/display-random-ad-every-second-post-genesis/ | |
*/ | |
function google_ad() { | |
if ( ! ( is_home() || is_category() ) ) { | |
return; | |
} | |
if ( ! function_exists( 'dfads' ) ) { | |
return; | |
} | |
global $wp_query; | |
if( ($wp_query->current_post % 2) == 1 ) { | |
echo dfads( 'groups=50&limit=1&orderby=random&container_class=adsense' ); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.adsense { | |
margin-bottom: 60px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment