-
-
Save Temmyhlee/c9afb4dba99641f99efaba7fe8a71b86 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
<?php | |
//* Do NOT include the opening php tag | |
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