Skip to content

Instantly share code, notes, and snippets.

@billerickson
Last active August 1, 2016 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save billerickson/394cb3328f2020e56fcf55678a261d3d to your computer and use it in GitHub Desktop.
Save billerickson/394cb3328f2020e56fcf55678a261d3d to your computer and use it in GitHub Desktop.
<?php
/**
* Start loop counter
*
*/
function be_start_loop_counter() {
global $be_loop_counter;
$be_loop_counter = 0;
}
add_action( 'genesis_before_loop', 'be_start_loop_counter' );
/**
* Column Classes based on loop counter
*
*/
function be_column_classes( $classes ) {
global $be_loop_counter;
$classes[] = 'one-half';
if( 0 == $be_loop_counter % 2 )
$classes[] = 'first';
return $classes;
}
add_filter( 'post_class', 'be_column_classes' );
/**
* After Post
*
*/
function be_after_post() {
// Increase the loop counter, since a post has been displayed
global $be_loop_counter;
$be_loop_counter++;
// Display ad
if( in_array( $be_loop_counter, array( 3, 7 ) ) ) {
be_display_ad();
$be_loop_counter++;
}
}
add_action( 'genesis_after_entry', 'be_after_post' );
// Output the page
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment