Skip to content

Instantly share code, notes, and snippets.

@aslamhindko
Created April 16, 2019 12:38
Show Gist options
  • Save aslamhindko/9458daefd197b5e0124ab241b7854e6e to your computer and use it in GitHub Desktop.
Save aslamhindko/9458daefd197b5e0124ab241b7854e6e to your computer and use it in GitHub Desktop.
<div class="news-wrap">
<?php
$q = new WP_Query(
array('post_type' => array('newswrap'),
'post_status' => array('publish'),
'orderby' => 'date',
'order' => 'ASC',
'posts_per_page' => 3
));
?>
<?php
$count = 1;
while ($q->have_posts()) : $q->the_post(); ?>
<?php $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(),'full', true); ?>
<?php if ($count == '1'): ?>
<div class="desfeature">
<div class="fetcol-1">
<div class="sectitle">
<h3><?php the_title(); ?></h3>
<?php the_content(); ?>
</div>
</div>
<div class="fetcol-2" style="background: url(<?php echo $thumbnail[0]; ?>) no-repeat top; background-size: cover;"></div>
<div class="clearfix"></div>
</div>
<?php $count++ ?>
<?php elseif ($count == '2'):
$count++; ?>
<div class="matinstwrp">
<div class="col-md-6">
<div class="micol2 pull-right">
<div class="sectitle">
<h3><?php the_title(); ?></h3>
<?php the_content(); ?>
</div>
</div>
<div class="micol" style="background: url(<?php echo $thumbnail[0]; ?>) no-repeat top; background-size: cover;">&nbsp;</div>
<div class="clearfix"></div>
</div>
<?php else: ?>
<div class="col-md-6">
<div class="micol2 pull-right newsWrp">
<div class="sectitle">
<h3><?php the_title(); ?></h3>
<?php the_content(); ?>
</div>
</div>
<div class="micol bg2" style="background: url(<?php echo $thumbnail[0]; ?>) no-repeat top; background-size: cover;">&nbsp;</div>
<div class="clearfix"></div>
</div>
<div class="clearfix"></div>
</div>
<?php endif ?>
<?php endwhile; ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment