-
-
Save ashleycam3ron/0d6625d09cecb8d7b2fdf052cb5ee53c to your computer and use it in GitHub Desktop.
check every nth post wordpress
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 | |
// $the_query would just be a standard WP_Query | |
if ( $the_query->have_posts() ) : | |
$counter = 1; | |
while ( $the_query->have_posts() ) : $the_query->the_post(); | |
if ( $counter % columns == 1 ) { | |
// do something at the start of your 'row' | |
} | |
// some content | |
// Check if $counter/$columns is equal to an integer | |
if ( is_int( $counter / $columns ) ) { | |
// do something at the end of your 'row' | |
} | |
$counter++ | |
endwhile; | |
// Reset WP_Query() data | |
wp_reset_postdata(); | |
endif; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment