Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created May 18, 2018 13:34
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 billerickson/62f13c58873f893d394283719c90a030 to your computer and use it in GitHub Desktop.
Save billerickson/62f13c58873f893d394283719c90a030 to your computer and use it in GitHub Desktop.
<?php
/**
* Insert CTA after first row of grid
* @author Bill Erickson
* @see https://www.billerickson.net/a-better-and-easier-grid-loop/#comment-699401
*/
function be_cta_after_first_row() {
// Only run on the grid
$grid = apply_filters( 'is_genesis_grid_loop', false );
if( ! $grid )
return;
// Only run before the 4th post (3 column grid )
global $wp_query;
if( 3 != $wp_query->current_post )
return;
// Display CTA
echo '<div class="cta-box"><h4>My CTA</h4><p>Lorem ipsum dolor sit amet</p></div>';
}
add_action( 'genesis_before_entry', 'be_cta_after_first_row' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment