Advertisement
kobial8

WP_Query Loop

Sep 27th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.28 KB | None | 0 0
  1.    <?php $loop = new WP_Query(array('post_type' => 'post', 'order' => 'DESC', 'category_name' => 'blog', 'posts_per_page' => 2)); ?>    
  2.                 <?php while($loop->have_posts()) : $loop -> the_post(); ?>
  3.                   <div class="col-sm-6">
  4.                     <article>
  5.                       <a href="<?php the_permalink(); ?>">
  6.                         <?php if ( has_post_thumbnail() ) {
  7.                          the_post_thumbnail('blog_img', array('class' => 'img-responsive'));
  8.                           } else { ?>
  9.                           <img src="<?php bloginfo('template_directory'); ?>/img/blog1.png" alt="<?php the_title(); ?>" />
  10.                       <?php } ?>
  11.                       </a>
  12.                       <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
  13.                       <div class="post-details">
  14.                         <i class="fa fa-user"></i> <?php the_author(); ?>
  15.                         <i class="fa fa-clock-o"></i> <time><?php the_date(); ?></time>
  16.                       </div> <!-- end of post details -->
  17.                       <div class="blog-summary text-justify">
  18.                         <?php the_excerpt(); ?>
  19.                       </div>
  20.                     </article>
  21.                   </div>
  22.             <?php endwhile; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement