Posts in 3 columns (2 posts)

    Posted 2 years ago #

    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.


    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">
      $loop = new WP_Query(array('post_type' => 'camp', 'posts_per_page' => 3));
      if ($loop->have_posts()) ?>
        <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
        $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(); ?>
    <?php endwhile; ?>

    Any ideas?

  2. alchymyth
    Forum Moderator
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic