• MrMACHOMAN84

    (@mrmachoman84)


    Hi everyone, I’d like to know if there’s a way to display posts in 3 columns. So the featured image, and right under it the post content.

    Basically:

    picture | picture | picture
    1 2 3

    I’ve been trying to do this with just css but it isn’t working out for me.

    Here’s what I have so far:

    <div id="main-wrapper">
    
    <?php
      $loop = new WP_Query(array('post_type' => 'camp', 'posts_per_page' => 3));
      if ($loop->have_posts()) ?>
        <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
        <?php
        $custom = get_post_custom($post->ID);
        $screenshot_url = $custom["screenshot_url"][0];
        $website_url = $custom["website_url"][0];
    ?>
    
        <div id="camp-boxes">
    <?php the_post_thumbnail( 'campcol'); ?>
     <?php the_content(); ?>
        </div>
    
    <?php endwhile; ?>
    
    </div>

    Any ideas?

Viewing 1 replies (of 1 total)
  • Michael

    (@alchymyth)

    edit this line:

    <div id="camp-boxes">

    you can’t use a css id, change that to a css class; add some code to check for the first post per row;

    <div class="camp-boxes<?php if( $loop->current_post%3 == 0 ) echo ' first'; ?>">

    css for that:

    .camp-boxes { float:left; width: 30%; margin-left: 5%; }
    .comp-boxes.first { margin-left: 0; clear:left; }

    for more suggestion, please post a live link to the web pages using that code.

Viewing 1 replies (of 1 total)
  • The topic ‘Posts in 3 columns’ is closed to new replies.