WordPress.org

Support

Support » Themes and Templates » [Resolved] displaying last 3 post on home page in a 3 colume layout

[Resolved] displaying last 3 post on home page in a 3 colume layout

  • im trying to get my last 3 post to display on my homepage as a 3 colum layout. The layout is divs and css and works fine but on the last colum it needs a class of “last”

    i cant for the love of me get the last one to display as last, here is where i got to.

    <?php for ($i = 1; $i <= 3; $i++) { ?>
    <?php
    $args = array( 'numberposts' => 3 );
    $lastposts = get_posts( $args );
    foreach($lastposts as $post) : setup_postdata($post); ?>
    <div class="boxes one_third <?php if ($i == 3) {echo "last";} ?>">
    <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    <?php the_content(); ?>
    </div>
    <?php endforeach; ?>
    <?php } ?>

    but this displays 3 post 3 time, so shows 9 post in all repeating

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] displaying last 3 post on home page in a 3 colume layout’ is closed to new replies.
Skip to toolbar