Last active
December 18, 2015 00:39
-
-
Save rfmeier/5698087 to your computer and use it in GitHub Desktop.
Display content after every 3rd post entry in the loop with Genesis
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 | |
/** pre Genesis 2.0 */ | |
add_action( 'genesis_after_post', 'custom_genesis_after_post' ); | |
/** Genesis 2.0+ */ | |
add_action( 'genesis_after_entry', 'custom_genesis_after_entry' ); | |
/** | |
* Callback for Genesis 'genesis_after_entry' action. | |
* | |
* Display a box after the entry. | |
* | |
* @package Genesis | |
* @category Loop | |
* @link http://my.studiopress.com/docs/hook-reference/ | |
* @author Ryan Meier @rfmeier http://www.rfmeier.net/ | |
* | |
* @global int $loop_counter current iteration | |
* @return none exit | |
*/ | |
function custom_genesis_after_entry(){ | |
global $loop_counter; | |
// if single, return | |
if( is_single() ) | |
return; | |
// use mode to get the remainder | |
$rem = $loop_counter % 3; | |
// if every 3rd, display the block (example code -- avoid inline styling!) | |
if( 0 == $rem ) | |
echo '<div style="width:100%;height:100px;background:#ff0000;margin-bottom: 40px;">Ad Space</div>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment