-
-
Save billerickson/62f13c58873f893d394283719c90a030 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 | |
/** | |
* 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