php - Wordpress - WP_Query, pulling in multiple post -


somewhat new wordpress , php , trying work though issue. have page (http://www.moderateindividual.com.php53-13.dfw1-1.websitetestlink.com/) , twards bottom can see section 6 images, need pulled in custom post type custom taxonomy. have pulling in 1 post on , over, how make pull in 6 latest post in category?

here code have far

<?php  //define custom post type name in arguments $args = array(     'post_type' => 'news',        'tax_query' => array(         array(             'taxonomy' => 'news_category',             'field'    => 'id',             'terms'    => '47',         ),         ),     ); //define loop based on arguments $loop = new wp_query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); ?>       <div class="st_views">         <div class="tab-1 st_view">           <div class="st_view_inner">             <div class="row cat-title">                 <p><span>as them shall seem likely…</span> / nullam quis dolor interdum erat dapibus aliquam. <a href="#">view all</a></p>             </div>             <div class="row top-stories">               <div class="small-12 medium-8 large-8 columns main-news img-wrap"> <?php the_post_thumbnail('home-featured-thumb'); ?>                 <div class="story-title">                   <h2><?php the_title(); ?></h2>                   <p><?php the_excerpt(); ?><a href="<?php the_permalink(); ?>" />read more</a></p>                 </div>               </div>               <!--end large-8 columns-->               <div class="large-4 small-12 medium-4 columns">                 <div class="row news-top img-wrap"> <a href="<?php the_permalink(); ?>" /><?php the_post_thumbnail('home-thumb'); ?></a>                   <div class="story-title-sub">                     <a href="<?php the_permalink(); ?>" /><h2><?php the_title(); ?></h2></a>                   </div>                 </div>                 <div class="row news-bottom img-wrap"> <a href="<?php the_permalink(); ?>" /><?php the_post_thumbnail('home-thumb'); ?></a>                   <div class="story-title-sub">                     <a href="<?php the_permalink(); ?>" /><h2><?php the_title(); ?></h2>                   </div>                 </div>               </div>               <!--end large-4 columns-->              </div>             <div class="row bottom-stories">               <div class="large-4 medium-4 small-12 columns img-wrap"> <a href="<?php the_permalink(); ?>" /><?php the_post_thumbnail('home-thumb'); ?></a>                 <div class="story-title-sub">                   <a href="<?php the_permalink(); ?>" /><h2><?php the_title(); ?></h2>                 </div>               </div>               <!--end large-4 columns-->               <div class="large-4 medium-4 small-12 columns img-wrap"> <a href="<?php the_permalink(); ?>" /><?php the_post_thumbnail('home-thumb'); ?></a>                 <div class="story-title-sub">                   <a href="<?php the_permalink(); ?>" /><h2><?php the_title(); ?></h2></a>                 </div>               </div>               <!--end large-4 columns-->               <div class="large-4 medium-4 small-12 columns img-wrap"> <a href="<?php the_permalink(); ?>" /><?php the_post_thumbnail('home-thumb'); ?></a>                 <div class="story-title-sub">                   <a href="<?php the_permalink(); ?>" /><h2><?php the_title(); ?></h2></a>                 </div>               </div>               <!--end large-4 columns-->              </div>             <!--end row-->            </div>           <!--end st view inner-->          </div>         <?php endwhile;?>         <!--end tab 1 st view--> 

the code above me searching google might work.

any or advice great.

you have make 2 loops , use offset parameter

<div class="st_views"> <div class="tab-1 st_view"> <div class="st_view_inner"> <?php  //define custom post type name in arguments $args = array(     'post_type' => 'news',        'tax_query' => array(         array(             'taxonomy' => 'news_category',             'field'    => 'id',             'terms'    => '47',         ),         ),     'posts_per_page' => 3     ); //define loop based on arguments $loop = new wp_query( $args ); if ( $loop->have_posts() ):?> <div class="row cat-title"> <p><span>as them shall seem likely…</span> / nullam quis dolor interdum erat dapibus aliquam. <a href="#">view all</a></p> </div> <div class="row top-stories"> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <?php if( $loop->current_post == 0 ){?>      <div class="small-12 medium-8 large-8 columns main-news img-wrap"> <?php the_post_thumbnail('home-featured-thumb'); ?>      <div class="story-title">            <h2><?php the_title(); ?></h2>            <p><?php the_excerpt(); ?><a href="<?php the_permalink(); ?>">read more</a></p>      </div> </div> <!--end large-8 columns--> <?php } elseif( $loop->current_post == 1 ){?> <div class="large-4 small-12 medium-4 columns"> <div class="row news-top img-wrap"> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('home-thumb'); ?></a>        <div class="story-title-sub">             <a href="<?php the_permalink(); ?>"><h2><?php the_title(); ?></h2></a>        </div> </div> <?php } elseif( $loop->current_post == 2 ){?>    <div class="row news-bottom img-wrap"> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('home-thumb'); ?></a>       <div class="story-title-sub">             <a href="<?php the_permalink(); ?>"><h2><?php the_title(); ?></h2></a>       </div> </div> </div> <!--end large-4 columns-->  <?php }?>  <?php endwhile;?>  </div>  <?php  endif; //end top stories?>             <?php  //define custom post type name in arguments $args2 = array(     'post_type' => 'news',        'tax_query' => array(         array(             'taxonomy' => 'news_category',             'field'    => 'id',             'terms'    => '47',         ),         ),     'posts_per_page' => 3,     'offset' => -3     ); //define loop based on arguments $loop2 = new wp_query( $args2 ); if ( $loop2->have_posts() ):?>           <div class="row bottom-stories">            <?php while ( $loop2->have_posts() ) : $loop2->the_post(); ?>             <div class="large-4 medium-4 small-12 columns img-wrap"> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('home-thumb'); ?></a>      <div class="story-title-sub">       <a href="<?php the_permalink(); ?>"><h2><?php the_title(); ?></h2></a>      </div> </div> <!--end large-4 columns--> <?php endwhile; ?> </div> <!--end bottom row-->  <?php endif;?>        </div> <!--end tab 1 st view inner-->          </div> <!--end tab 1 st view-->  </div> <!--end st view--> 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -