How to Show Posts in Even Odd Format 1 Wordpress

<?php global $post;

$args = array( 'numberposts' => 2, 'category_name' => 'site-plan' );

$posts = get_posts( $args );

$i=1;

foreach( $posts as $post ): setup_postdata($post);

$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID, 'thumbnail') );

if($i%2){

//$i%2 ? 'odd':'even') ?>

  <div class="container white-block">

    <div class="row margin-top-25">

      <div class="col-md-6 col-sm-6">

        <img src="<?php echo $url; ?>"alt="image" class="img-responsive img-align">

      </div>

      <div class="col-md-6 col-sm-6">

        <h3 class="yellow-center-sub-heading erase-margin"><?php the_title();?></h3>

        <p class="artical-text"><?php the_content();?></p>

      </div>

    </div>

    <?php   } else { ?>

    <div class="row margin-top-25">

      <div class="col-md-6 col-sm-6">

        <h3 class="yellow-center-sub-heading erase-margin"><?php the_title();?></h3>

        <p class="artical-text"><?php the_content();?></p>

      </div>

      <div class="col-md-6 col-sm-6">

        <img src="<?php echo $url; ?>"alt="image" class="img-responsive img-align">

      </div>

    </div>

  </div>

  <?php } $i++; endforeach; ?>

Comments

Popular posts from this blog

Get Post Data From Simple Post custom shortcode

Top 20 Beautiful Pen For Writing

Fatal error: Maximum execution time of 300 seconds exceeded in C:\xampp\phpMyAdmin\libraries\classes\Dbi\DbiMysqli.php on line 199