Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'genesis_after_entry', 'sk_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 sk_ad() {
- // if we are not on Posts page or category archive, abort.
- if ( ! ( is_home() || is_category() ) ) {
- return;
- }
- // if Ads by datafeedr.com plugin is not active, abort.
- if ( ! function_exists( 'dfads' ) ) {
- return;
- }
- // if this is a paginated page, abort.
- if ( is_paged() ) {
- return;
- }
- global $wp_query;
- if( $wp_query->current_post == 1 || $wp_query->current_post == 3 ) { // if 2nd or 4th post
- echo dfads( 'groups=-1&limit=1&orderby=random' );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement