Need a 2 column custom post type
-
I am using twentyeleven theme (AND A CHILD THEME) and have my custom post types set up. I’d like to have two columns of blog posts (not a sidebar).
I found this code on digital raindrops that I’d like to incorporate into the page but I don’t know how. I tried it a few different ways and it came out botched. Would really appreciate your help.
<?php /* Start Two Column Support */ ?> <?php $counter = 1; ?> <?php /* Start the Loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <?php /* Two Column Support get class */ ?> <?php $class = ( $counter % 2 ? ' one' : '' ) ?> <?php $first = ( $counter < 3 ? ' first' : '' ) ?> <?php /* Two Column output open the div class */ ?> <div class="column<?php echo $class; echo $first; ?>"> <?php get_template_part( 'content', 'index' ); ?> <?php /* End Two Column Support close div class */ ?></div> <?php $counter++; //Update Counter ?>
and the custom post type code is:
<?php while ( have_posts() ) : the_post(); $args = array( 'post_type' => 'custom-a', 'posts_per_page' => 6 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); the_title('<h2 class="custom-a-title">','</h2>'); echo '<div class="custom-a-post">'; the_excerpt(); echo '</div>'; endwhile; // end of the loop. ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Need a 2 column custom post type’ is closed to new replies.