• I am currently using the code provided below to split posts up by date. What I am trying to achieve is to split the two different CPT’s being queried into separate columns under each date. As of now it lists both post types together. Anyone know if this is even possible?

    Example of what I’m trying to achiev.

    <?php
    $day_check = '';
       $index = new WP_Query( array(
          'orderby'=>'post_date',
          'post_type' => array('cpt1', 'cpt2'),
          'posts_per_page' =>12
       ));
       while ( $index->have_posts() ) : $index->the_post();
          $day = get_the_date('j');
          if ($day != $day_check) {
             if ($day_check != '') {
                echo '</div></div>'; // close the list here
             }
             echo '<div class="day"><div class="date">' . get_the_date() . '</div><div class="posts">';
          }?>
          <li class="post"><?php the_title(); ?>
       <?php $day_check = $day; endwhile; ?>
       <?php if ( $index->have_posts() ) :?>
    <?php endif; ?>

    The desired output would look something like this..

    <div class="day">
       <div class="date">
          December 24, 2013
       </div>
       <div class="cpt1">
          //Posts from "CPT1" go here
       </div>
       <div class="cpt2">
          //Posts from "CPT2" go here
       </div>
    </div>
    
    ..repeat for next day...
  • The topic ‘Split Custom Post Types into separate columns within loop’ is closed to new replies.