Insert Custom “Entry/Advertisement” to the Blog Grid
add_action( 'wpex_hook_archive_loop_before_entry', function() {
// Add extra content only for blog archives
if ( 'blog' != wpex_get_index_loop_type() ) {
return;
}
global $wp_query;
// Insert after the 3rd item (note in WP the first item has an index of 0)a
if ( 2 == $wp_query->current_post ) {
// Add to global entry counter
global $wpex_count;
$wpex_count++;
// Get classes for blog posts (need if you are inserting into a grid)
$classes = wpex_blog_entry_classes();
// Your custom content
echo '<div class="' . implode( ' ', $classes ) . '">Custom item added after the first 3 posts</div>';
}
} );
All PHP snippets should be added via child theme's functions.php file or via a plugin (we recommend Code Snippets)