Use the global $page
, which holds the current page number.
// Somewhere near the top
if ( $GLOBALS['page'] === 1 && $image_data = get_post_thumbnail_id() ) {
if ( $image_data = wp_get_attachment_image_src( $image_data, 'full' ) ) {
if ( $image_data[1] >= 500 )
the_post_thumbnail( 'top-post' );
}
}
// Further down. $image_data still exists, no need to grab it again.
if ( $GLOBALS['page'] === 1 && $image_data && $image_data[1] < 500 )
the_post_thumbnail();
You’ll see I also a did a little spring cleaning:
- Removed redundant second
$image_data = ...
- Added check that there is indeed a thumbnail
- Added check that
$image_data
exists