-
-
Save billerickson/394cb3328f2020e56fcf55678a261d3d to your computer and use it in GitHub Desktop.
This file contains 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 | |
/** | |
* 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