• Hi
    Not sure if this is the right thread soory if not.
    I am using the accessmag theme which shows 2 large posts side by side and then smaller posts underneath. I would like it to show 1 large posts and then smaller posts underneath but I sm struggling to change the loop with the counter.

    <div class="first-block-wrapper">
    
                        <h3 class="block-cat-name"> 
    
                            <span><?php echo esc_attr( $category_info->name ) ; ?></span>
    
                        </h3>
    
                        <div class="block-post-wrapper clearfix">
    
                        <?php                                
    
                            $block1_args = array(
    
                                                'category_name' => $block1_cat,
    
                                                'post_status' => 'publish',
    
                                                'posts_per_page' => $posts_for_block1,
    
                                                'order' => 'DESC'
    
                                                );
    
                            $block1_query = new WP_Query( $block1_args );
    
                            $b_counter = 0;
    
                            $total_posts_block1 = $block1_query->found_posts;
    
                            if( $block1_query->have_posts() ) {
    
                                while( $block1_query->have_posts() ) {
    
                                    $b_counter++;
    
                                    $block1_query->the_post();
    
                                    $b1_image_id = get_post_thumbnail_id();
    
                                    $b1_big_image_path = wp_get_attachment_image_src( $b1_image_id, 'accesspress-mag-block-big-thumb', true );
    
                                    $b1_small_image_path = wp_get_attachment_image_src( $b1_image_id, 'accesspress-mag-block-small-thumb', true );
    
                                    $b1_image_alt = get_post_meta( $b1_image_id, '_wp_attachment_image_alt', true );
    
                        ?>
    
                            <?php if( $b_counter == 1 ){ echo '<div class="toppost-wrapper">'; } if( $b_counter > 2 && $b_counter == 3 ){ echo '<div class="bottompost-wrapper">'; }?>
    
                            <div class="single_post clearfix <?php if( $b_counter <= 2 ){ echo 'top-post non-zoomin'; }?>">
    
                                <?php if( has_post_thumbnail() ) { ?>   
    
                                    <div class="post-image"><a href="<?php the_permalink();?>"><img src="<?php if( $b_counter <= 2 ){echo esc_url( $b1_big_image_path[0] );}else{ echo esc_url( $b1_small_image_path[0] ) ;}?>" alt="<?php echo esc_attr($b1_image_alt);?>" /></a>
    
                                        <?php if( $b_counter <= 2 ) { ?> <a class="big-image-overlay" href="<?php the_permalink();?>"><i class="fa fa-external-link"></i></a><?php } ?>
    
                                    </div><!--. post-image-->
    
                                <?php } ?>
    
                                    <div class="post-desc-wrapper">
    
                                        <h3 class="post-title"><a href="<?php the_permalink();?>"><?php the_title();?></a></h3>
    
                                        <div class="block-poston"><?php do_action('accesspress_mag_home_posted_on');?></div>
    
                                    </div><!-- .post-desc-wrapper -->
    
                                    <?php if( $b_counter <= 2 ) { ?><div class="post-content"><?php echo '<p>'. accesspress_mag_word_count( get_the_content(), 25 ) .'</p>' ;?></div><?php } ?>
    
                            </div><!-- .single_post -->
    
                            <?php 
    
                                if( $b_counter %2 == 0 ){ echo '<div class="clearfix"></div>'; }
    
                                if( $b_counter > 2 && $b_counter == $total_posts_block1 ){ echo '</div>'; }
    
                                if( $b_counter ==2 ){ echo '</div>'; }
    
                            ?>
    
                        <?php
    
                                }
    
                            }//endif wp_query
    
                        ?>
    
                        </div><!-- .block-post-wrapper -->
    
                    </div><!-- .first-block-wrapper -->

    If any body could help that would be fantastic

  • The topic ‘using the counter and loop’ is closed to new replies.