jlittlejohn
9/26/2012 - 4:29 PM

WP: Query Database

WP: Query Database

<?php

  $args = array(
    'post_type' => 'slide-show',
    'post_status' => 'publish',
    'orderby' => 'menu_order',
    'order' => 'DESC',
    'tax_query' => array(
      array(
        'taxonomy' => 'slide-show-category',
        'field' => 'slug',
        'terms' => 'home'
      )
    )
  );

  $loop = new WP_Query( $args );
  $i = 0;
  if ($loop->have_posts()) : while ($loop->have_posts()) : $loop->the_post(); 
  $i++;
  // $postCount = count($posts);
  $image = get_field('add_image');
  ?>
  <div class="<?php if ($i == 1) { echo 'active'; } ?> item">
    <?php the_title(); ?>
    <?php echo $image['description']; ?>
    <img src="<?php echo $image['sizes']['homepage-slide']; ?>" alt="">
  </div>
<?php endwhile; endif; wp_reset_postdata();?>