Support » Themes and Templates » Special Last Post

  • I’m coding from scratch and was wondering how to make the most recent post have a different layout/set up on the index page then the ones beneath it, sort of like a featured article or headline in a newspaper.

Viewing 1 replies (of 1 total)
  • One way to do it is to use two loops on the page, add some classes to the featured post display, and style using CSS

    <div class="featured">
       <?php $recent = new WP_Query("cat=1&amp;showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
         <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    	<?php the_content(__('Read the story &raquo;'));?>
       <?php endwhile; ?>

    The put a query posts before the main WP loop that skips the most recent post, to avoid duplicating it

    <?php query_posts('offset=1'); ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Special Last Post’ is closed to new replies.