Skip to content

Instantly share code, notes, and snippets.

@antiden
Created January 9, 2017 07:08
Show Gist options
  • Save antiden/3fdde6f1142f20b554f98b01b00b6c8a to your computer and use it in GitHub Desktop.
Save antiden/3fdde6f1142f20b554f98b01b00b6c8a to your computer and use it in GitHub Desktop.
WP Post Loop
<?php if ( have_posts() ) : ?>
<?php $main_news_first = new WP_Query('category_name=news&posts_per_page=1'); ?>
<?php while ($main_news_first->have_posts()) : $main_news_first->the_post(); ?>
<div class="main_news_first">
<div class="main_news_first__box">
<div class="main_news_first__box--image">
<?php
$params = array( 'width' => 1200, 'height' => 500 );
$bfi_image = bfi_thumb(get_field('thumb'), $params);
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php echo $bfi_image; ?>" alt="<?php the_title; ?>"></a>
</div>
<div class="main_news_first__box--info">
<div class="date"><?php the_date('d F Y'); ?></div>
<div class="title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></div>
</div>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment