Insert a DIV after the 6th product only once in WooCommerce category archives



PHP Snippet 1:

if ($current_post == 6) :

PHP Snippet 2:


add_action( 'woocommerce_shop_loop', 'action_woocommerce_shop_loop', 100 );
function action_woocommerce_shop_loop() {

    if ( is_product_category() ) :
        
    global $wp_query;
    
    $columns = esc_attr( wc_get_loop_prop( 'columns' ) );
    
    $current_post = $wp_query->current_post;
    
    if ( ( $current_post % $columns ) == 0  && (in_array($current_post, array (6, 10, 45)))) :
    
    ?>
   </ul>
    <ul class="columns-1" style="list-style:none; margin:0 0 3em;">
        <li style=""><div class="banner"> 
            
        <!--Insert Ads here -->

        </div></li>
    </ul>
    <ul class="products columns-<?php echo $columns; ?>">
    
        <?php
    endif;endif;
}