• Resolved adeemer

    (@adeemer)


    I’ve spent a while searching the forums and google, but can’t find discussion on this.

    I’m trying to promo the most recent story at the top of my homepage, with the second, third, and fourth most recent stories (of any category) presented in a different style, to the right of that. Basically, a standard newspaper-style display.

    Any recommendations?

    Thx!

Viewing 3 replies - 1 through 3 (of 3 total)
  • This is not exactly what you want, but should point you in the right direction. You would replace the call to the_post_thumbnail() with the_content() and modify the check on the number of posts to add a fourth to the vertical group.

    In the small loop below, I’ve set $firstpost = ‘ first’, note the space if you’re using it along with other CSS classes.

    The first post has a class of first, and the remaining 4 posts in the loop have the class ‘second’ (before the endwhile call I set the $firstpost variable to second, which should allow you to style them differently while keeping the same overall format.

    <?php
    $postargs=array(
       'showposts' => 5,
       'cat' => $catid,
       'orderby' => 'date',
       'order' => 'DESC'
       );
    
    $category_box = new WP_Query($postargs);
    	$firstpost = ' first';
    	while ($category_box->have_posts()) :
    		$category_box->the_post();
    ?>
    <div id="post-<?php the_ID(); ?> " class="post-<?php the_ID(); ?> post hentry teaser<?php echo $firstpost; ?>">
    
    ..... POST FORMAT HERE .....
    
    </div>
    <?php
      $firstpost = ' second';
      endwhile; /* end while have_posts() */
    
    ?>

    Hope this works for you or at least helps.

    Thread Starter adeemer

    (@adeemer)

    @harmck, exactly what I was looking for! thanks so much!! (and thanks, @vtxyzzy!)

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display 2nd-, 3rd-, and 4th-most recent stories on homepage’ is closed to new replies.