Skip to content

Instantly share code, notes, and snippets.

@senlin
Last active August 29, 2015 14:03
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 senlin/5ba1df2e2f6cae1082be to your computer and use it in GitHub Desktop.
Save senlin/5ba1df2e2f6cae1082be to your computer and use it in GitHub Desktop.
add 4th image different size to query; LinkedIn post http://lnkd.in/dbxp28Z
<?php
/**
* add 4th image different size to query; LinkedIn post http://lnkd.in/dbxp28Z
*
*/
/* Cleaner to write arguments separately; 'order_by' => 'date' is not necessary as that is the default */
$args = array(
'post_type' => 'post',
'category_name' => 'uitgelicht',
'posts_per_page' => 4
);
$q_featured = new WP_Query( $args );
$counter = 0;
while ( $q_featured->have_posts() ) {
$q_featured->the_post();
echo '<div class="blocks">';
if ( $counter == 3 ) { // i.e. the 4th iteration ?>
<a rel="featured-home" href="<?php the_permalink(); ?>?popup=1" title="<?php the_title(); ?>">
<?php
/**
* In your functions.php you will need to add a new image size
* with the same name as below which you can size as you wish
*/
get_the_post_thumbnail( $post->ID, 'front-page-double-size' ) ?>
</a>
<?php } else { ?>
<a rel="featured-home" href="<?php the_permalink(); ?>?popup=1" title="<?php the_title(); ?>">
<?php get_the_post_thumbnail( $post->ID, 'front-page-small' )?>
</a>
<?php }
$counter++;
echo '</div>'; // end .blocks
} //endwhile
wp_reset_postdata();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment