Skip to content

Instantly share code, notes, and snippets.

@taniarascia
Created December 10, 2015 19:10
Show Gist options
  • Save taniarascia/f222f591ee68ec9ebc57 to your computer and use it in GitHub Desktop.
Save taniarascia/f222f591ee68ec9ebc57 to your computer and use it in GitHub Desktop.
Apply code to only first post
<?php if (have_posts()) : ?>
<?php $post = $posts[0]; $c=0;?>
<?php while (have_posts()) : the_post(); ?>
<?php $c++;
if( $c == 1) :?>
<h1>The first post on the main index page</h1>
<?php the_title(); ?>
<?php the_excerpt(); ?>
<?php else :?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php endif;?>
<?php endwhile; ?>
<!-- page nav -->
<?php endif; ?>`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment