Skip to content

Instantly share code, notes, and snippets.

@rfmeier
Last active December 18, 2015 00:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rfmeier/5698087 to your computer and use it in GitHub Desktop.
Save rfmeier/5698087 to your computer and use it in GitHub Desktop.
Display content after every 3rd post entry in the loop with Genesis
<?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