Two Column of Posts (two posts per row) (4 posts)

  1. jadenwork1
    Posted 3 years ago #

    Hi everyone,

    I want to have two posts per row. I have made my theme from what I've learned on this page this morning, WPTUTS.

    This is my coding for my index.php page.

    <?php get_header(); ?>
    <?php /* If there are no posts to display, such as an empty archive page */ ?>
    <?php if ( ! have_posts() ) : ?>
            <h1>Not Found</h1>
                <p>Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post</p>
    <?php endif; ?>
    <?php while ( have_posts() ) : the_post(); ?>
    <div class="post">
        <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
        <div class="post-details">
            <div class="post-details-left">
            Posted on <strong><?php the_date(); ?></strong> by <span class="author"><?php the_author(); ?></span> under <span class="author"><?php the_category(', '); ?></span>
            <div class="post-details-right">
            <?php edit_post_link('Edit', '<span class="comment-count">  ' , '</span>'); ?><span class="comment-count"><?php comments_popup_link('Leave a comment', '1 Comment', '% Comments'); ?></span>
        <?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
                <?php the_excerpt(); ?>
        <?php else : ?>
                <?php the_content('Read More'); ?>
        <?php endif; ?>
        <div class="dots"></div>
    </div><!-- post -->
    <?php endwhile; ?>
    <?php if ( $wp_query->max_num_pages > 1 ) : ?>
            <div id="older-posts"><?php next_posts_link('Older Posts'); ?></div>
            <div id="newer-posts"><?php previous_posts_link('Newer Posts'); ?></div>
    <?php else: ?>
            <div id="only-page">No newer/older posts</div>
    <?php endif; ?>
    <div class="spacer"></div>
    <?php get_footer(); ?>

    If anyone could help it would be greatly appreciated as I've been trying to figure it out for hours. (I'm going crazy -_-)

    Thank you,

  2. Andrew Nevins
    Forum moderator
    Posted 3 years ago #

    This query may be better suited in a css-specific forum.

  3. jadenwork1
    Posted 3 years ago #

    Isn't possible to seperate the even and odd posts from one another and have one column that presents the odd posts and the even posts ?

  4. Andrew Nevins
    Forum moderator
    Posted 3 years ago #

    This is possible.
    Look at floating the posts left, then look at adding nth-child(2n+1) with clear left to the posts.

Topic Closed

This topic has been closed to new replies.

About this Topic