Skip to content

Instantly share code, notes, and snippets.

@JayWood
Created November 10, 2014 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JayWood/a4ddde89cc0ff16bb364 to your computer and use it in GitHub Desktop.
Save JayWood/a4ddde89cc0ff16bb364 to your computer and use it in GitHub Desktop.
different thumbnail for last post
<?php while (have_posts()) : the_post(); ?>
<?php if (is_paged()) : ?>
<?php $postclass = ('regular'); ?>
<?php else : ?>
<?php $postclass = ($post == $posts[0]) ? 'featured' : 'regular'; ?>
<?php endif; ?>
<div class="<?php echo $postclass; ?>">
<div class="thumbnail">
<!-- post thumbnail -->
<?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php
// Use wp_query to check the current post we're on, and then check the post count.
if ( isset( $wp_query ) && $wp_query->current_post == $wp_query->post_count ){
the_post_thumbnail( array( 1920, 1080 ) ); // Large image
} else {
the_post_thumbnail( array( 583, 420 ) );
}
?>
</a>
<?php endif; ?>
<!-- /post thumbnail -->
</div>
<detail>
<!-- post title -->
<h2>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</h2>
<!-- /post title -->
<!-- post details -->
<span class="date"><?php the_time('F j, Y'); ?> <?php the_time('g:i a'); ?></span>
<span class="author"><?php _e( 'Published by', 'html5blank' ); ?> <?php the_author_posts_link(); ?></span>
<span class="comments"><?php if (comments_open( get_the_ID() ) ) comments_popup_link( __( 'Leave your thoughts', 'html5blank' ), __( '1 Comment', 'html5blank' ), __( '% Comments', 'html5blank' )); ?></span>
<!-- /post details -->
<?php html5wp_excerpt('html5wp_index'); // Build your custom callback length in functions.php ?>
<?php edit_post_link(); ?>
</detail>
</div>
<?php comments_template() ?>
<?php endwhile ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment