How to write a series of posts wordpress?

Tell me there is a structure of alternating blocks as tiles, and take data from the page posts,how do I correctly write the loop output ,because if I'm two blocks will cram in one cycle they will alternate , but to load the same information from the admin panel? here is the code

<?php $args = array(
 'post_type' =--> 'glavnaya',
 'posts_per_page' => -1
);
$glavnaya= new WP_Query( $args );

?>

<?php if( $glavnaya--->have_posts() ) : while ( $glavnaya->have_posts() ) : $glavnaya->the_post(); ?>
 <div class="work" id="work">
 <div class="photo" id="photo"> 
 <?php echo the_content();?>
</div>
 <div class="above" id="above">
the text from the post
 <span class="town">text post</span>
</div>
</div>

<div class="work">
 <div class="above">
 Design men's bedrooms.<br><br>

 <span class="town">Text post</span>
</div>
 <div class="photo">
<?php echo the_content();?>
</div>
</div> 
<?php endwhile; else: ?>
 the <h3>no Records</h3>
<?php endif; ?>


here is the website so you can see, the answer seems close,but in my head what the extra counters i check the array positions on the parity,can not articulate
The website borisov.cloud
June 10th 19 at 14:28
1 answer
June 10th 19 at 14:30
Solution
maybe there are some variants of implementation?to be in the loop of WordPress display all

The simplest that comes to mind is to add the flag and hand it over to. Something like:
<?php $args = array(
 'post_type' =--> 'glavnaya',
 'posts_per_page' => -1
);
$glavnaya= new WP_Query( $args );

?>

<?php $flag = true; if( $glavnaya--->have_posts() ) : while ( $glavnaya->have_posts() ) : $glavnaya->the_post(); ?>
<?php if($flag) : ?>
The block with the picture after the text
<?php else : ?>
The block with the picture before the text
<?php endif; ?>
<?php $flag = !$flag; endwhile; else: ?>
 the <h3>no Records</h3>
<?php endif; ?>
thanks,exactly the answer I wanted,I feel that somewhere close by, but all the counters and parity climb is exactly what you need. - Burnice_Schroed commented on June 10th 19 at 14:33

Find more questions by tags WordPress